3d-array-to-string 中文文档教程
3d-array-to-string
一个将数组转换为字符串的小型库。
Usage
Install
通过 npm 或 yarn 安装:npm install 3d-array-to-string</
Example
code>
Parameters
array
: input array (3 dimensional)width
: width of arrayheight
: height of arraynSlices
: number of slices of arrayoriginal
: the unique elements of arrayconversion
: the string corresponding to originalspacePaddingNumber
: number of space following a stringlinePaddingNumber
: line spacingspaceSeparation
: slice separator string
import { arrayToString } from "array-to-string";
// OR:
// const arrayToString = require('3d-array-to-string').arrayToString;
const array = [
1, 1, 1, 1, 1, 0, 2, 3, 0, 3, 0, 2, 2, 0, 0, 0, 0, 2, 2, 0, 1, 0, 0, 2, 2, 1,
1, 1, 1, 2,
];
console.log(
arrayToString(array, 6, 5, 1, [0, 1, 2, 3], ["0", "1", "2", "3"], 1)
);
// 111110
// 230302
// 200002
// 201002
// 211112
console.log(
arrayToString(array, 6, 5, 1, [0, 1, 2, 3], [" ", "_", "|", "."], 1)
);
// _____
// |. . |
// | |
// | _ |
// |____|
3d-array-to-string
A small library which converts an array to a string.
Usage
Install
Install via npm or yarn: npm install 3d-array-to-string
Example
arrayToString(array, width, height, nSlices, original, conversion, spacePaddingNumber, linePaddingNumber, sliceSeparation)
Parameters
array
: input array (3 dimensional)width
: width of arrayheight
: height of arraynSlices
: number of slices of arrayoriginal
: the unique elements of arrayconversion
: the string corresponding to originalspacePaddingNumber
: number of space following a stringlinePaddingNumber
: line spacingspaceSeparation
: slice separator string
import { arrayToString } from "array-to-string";
// OR:
// const arrayToString = require('3d-array-to-string').arrayToString;
const array = [
1, 1, 1, 1, 1, 0, 2, 3, 0, 3, 0, 2, 2, 0, 0, 0, 0, 2, 2, 0, 1, 0, 0, 2, 2, 1,
1, 1, 1, 2,
];
console.log(
arrayToString(array, 6, 5, 1, [0, 1, 2, 3], ["0", "1", "2", "3"], 1)
);
// 111110
// 230302
// 200002
// 201002
// 211112
console.log(
arrayToString(array, 6, 5, 1, [0, 1, 2, 3], [" ", "_", "|", "."], 1)
);
// _____
// |. . |
// | |
// | _ |
// |____|