Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dup

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dup

Initialize an array of arrays to a constant

  • 0.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
178K
decreased by-17.02%
Maintainers
1
Weekly downloads
 
Created
Source

dup

Initializes an n-dimensional array to a constant value.

Install

npm install dup

Example

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' 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

Keywords

FAQs

Package last updated on 10 Apr 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc