# dup

> Initialize an array of arrays to a constant

Latest version **1.0.0** (published 2014-04-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install dup
pnpm add dup
yarn add dup
bun add dup
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2014-04-28 |
| First published | 2013-04-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Mikola Lysenko |
| Maintainers | mikolalysenko |
| Keywords | dup, initialize, array, constant, numeric, rep, zeros, matlab, clear, ndarray, grid, matrix, vector, tensor |

## Links

- npm: https://www.npmjs.com/package/dup
- Repository: https://github.com/mikolalysenko/dup
- Issues: https://github.com/mikolalysenko/dup/issues
- npm.io page: https://npm.io/package/dup

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2014-04-28
- 0.0.0 — 2013-04-10

## README

# dup
Initializes an n-dimensional array to a constant value.

## Install

    npm install dup
    
## Example

```javascript
var dup = require("dup")

console.log(dup(5))

//Prints:
//
//    [0, 0, 0, 0, 0]
//


console.log(dup([3,2], 1))

//Prints:
//
//    [[1, 1],
//     [1, 1],
//     [1, 1]]
//
```

## `require("dup")(shape[, value])`
Initializes an array to a constant value

* `shape` Either an array of dimensions or a scalar, representing the shape of the array to create.
* `value` The value to initialize the array with.  Default is 0

**Returns** An n-dimensional array with the given shape and value

## Rationale
I often find myself using [numeric.js'](http://www.numericjs.com/) `rep` method in my projects.  However, for many things pulling in all of numeric.js is total overkill, especially for code that ultimately needs to run on the browser.  So I decided to make this library which just implements the `rep` and nothing else in the spirit of promoting modularity by smaller and more numerous packages.

# Credits
(c) 2013 Mikola Lysenko. MIT License

---
_Source: https://npm.io/package/dup · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
