2djs
JavaScript library for 2-dimensional array.
Install
npm install --save 2djs
or,
yarn add 2djs
API
constructor
;const items = 1 2 3 4 5 6 7 8 9 10 11 12;const array = items;
get()
const items = 1 2 3 4 5 6 7 8 9 10 11 12 ;const array = items;array; // [ [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12] ]
stat()
console; rowSize: 3 columnSize: 4;
clear()
arrayclear; // []
rowSize()
const items = 1 2 3 4 5 6 7 8 9 10 11 12 ;const array = items;array; // 3
columnSize()
const items = 1 2 3 4 5 6 7 8 9 10 11 12 ;const array = items;array; // 4
at(rowPosition, columnPosition)
const items = 1 2 3 4 5 6 7 8 9 10 11 12 ;const array = items;array; // 1array; // 11array; // null
row(position)
const items = 1 2 3 4 5 6 7 8 9 10 11 12 ;const array = items;array; // [1, 2, 3, 4]array; // [9, 10, 11, 12]
column(position)
const items = 1 2 3 4 5 6 7 8 9 10 11 12 ;const array = items;array; // [1, 5, 9]array; // [3, 7, 11]
rows()
const items = 1 2 3 4 5 6 7 8 9 10 11 12 ;const array = items;arrayrows; // [ [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], ]
columns()
const items = 1 2 3 4 5 6 7 8 9 10 11 12 ;const array = items;array; // [ [ 1, 5, 9 ], [ 2, 6, 10 ], [ 3, 7, 11 ], [ 4, 8, 12 ] ]
firstRow()
const items = 1 2 3 4 5 6 7 8 9 10 11 12 ;const array = items;array; // [1, 2, 3, 4]
firstColumn()
const items = 1 2 3 4 5 6 7 8 9 10 11 12 ;const array = items;array; // [1, 5, 9]
lastRow()
const items = 1 2 3 4 5 6 7 8 9 10 11 12 ;const array = items;array; // [9, 10, 11, 12]
lastColumn()
const items = 1 2 3 4 5 6 7 8 9 10 11 12 ;const array = items;array; // [4, 8, 12]
add(twoDimensionalArray)
const items = 1 2 3 4 5 6 7 8 9 10 11 12 ;const array = items;const arr = 13 14 15 16 17 18 19 20 ;array; // [ [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ], [ 9, 10, 11, 12 ], [ 13, 14, 15, 16 ], [ 17, 18, 19, 20 ] ]
addRow(row)
const items = 1 2 3 4 5 6 7 8 9 10 11 12 ;const array = items;array; // [ [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ], [ 9, 10, 11, 12 ], [ 13, 14, 15, 16 ] ]
addColumn(column)
const items = 1 2 3 4 5 6 7 8 9 10 11 12 ;const array = items;array; // [ [ 1, 2, 3, 4, 2 ], [ 5, 6, 7, 8, -1 ], [ 9, 10, 11, 12, 1 ] ]
isMember(item)
const items = 1 2 3 4 5 6 7 8 9 10 11 12 ;const array = items;array; // truearray; // false
License
Copyright (c) 2020 kenju
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.