JSPM

inda

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q30823F
  • License ISC

Initialize new dimensional array

Package Exports

  • inda

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (inda) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Initialize new dimensional array

Create a new multi-dimensional array with initialized values.

Example

let inda = require('inda');

// A single-dimensional array where all values are 23
inda(23, 3);
// [23, 23, 23]

// An array with different values via callback
let i = 0;
inda(() => i++), 3);
// [0, 1, 2]

// A two-dimensional array
inda(1, 2, 3);
// [[1, 1, 1], [1, 1, 1]]

// A 12-dimensional array
inda(1, ...inda(1, 12));
// [[[[[[[[[[[[1]]]]]]]]]]]]

// Assigning a function as a value
inda(() => () => 6, 2);
// [() => 6, () => 6)]

Installation

$ npm install inda

API

var inda = require('inda');

inda(initialValue, size, ...sizes)

Type Data Type Name Description
parameter * initialValue A value to each element in the array. If a callback is provided, the returned value will be used.
parameter number size The size of the array to return.
parameter ...number sizes The sizes of nested-arrays.
returns *[] An array of initialized values.