Skip to content

About

Commonly used array initializer that optimizes for length.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

@tsdotnet/array-init: Pre-size arrays. A fixed length, ready to fill.

npm version GitHub license

Create an array of a given length, ready to fill.

Install

npm install @tsdotnet/array-init

Usage

import arrayInit from '@tsdotnet/array-init';

const row = arrayInit<number>(5); // length 5, ready to fill
row.length; // 5

for (let i = 0; i < row.length; i++) row[i] = i * i;
// [0, 1, 4, 9, 16]

Use it from

ESM (import arrayInit from '@tsdotnet/array-init';) or CommonJS (const arrayInit = require('@tsdotnet/array-init').default;).

In a browser, without a bundler
<script src="https://cdn.jsdelivr.net/npm/@tsdotnet/array-init@1/dist/umd/array-init.min.js"></script>
<script>
  const arrayInit = tsdotnet.arrayInit.default;
</script>

Docs

tsdotnet.github.io/array-init

About

Commonly used array initializer that optimizes for length.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages