0.10.1 • Published 8 years ago

matrix-transposer v0.10.1

Weekly downloads
1
License
MIT
Repository
-
Last release
8 years ago

matrix-transposer

npm.io Code Climate

Abstract

Transpose 2D array.

License

MIT

install

$ npm install --save matrix-transposer

import

Node.js

var MatrixTransposer = require('matrix-transposer').default;

EcmaScript2015

import MatrixTransposer from 'matrix-transposer';

How to use

Example 1

var array = [
  [1, 2, 3],
  [4, 5, 6]
];

var result = MatrixTransposer.arrayTranspose(array);
// result
// [
//   [1, 4],
//   [2, 5],
//   [3, 6]
// ]

Example 2

var array = [
  [1],
  [4, 5, 6]
];

// option
var option = {
  referenceIndex: 1, // default: 0 
  defaultValue: 0 // default: null
};

var result = MatrixTransposer.arrayTranspose(array, option);
// result
// [
//   [1, 4],
//   [0, 5],
//   [0, 6]
// ]
var array = [
  [1],
  [4, 5, 6]
];

// option
var option = {
  referenceIndex: 0, // default: 0 
  defaultValue: 0 // default: null
};

var result = MatrixTransposer.arrayTranspose(array, option);
// result
// [
//   [1, 4]
// ]
0.10.1

8 years ago

0.10.0

8 years ago

0.9.0

8 years ago