New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

node-twiddle

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-twiddle

Generate all combinations of `k` out of `n` objects

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

node-twiddle

Rewrite in NodeJS the Chase's Twiddle algorithm that returns all combinations of m out of n objects.

The C implementation can be found here.

API

Import library

const NodeTwiddle = require('node-twiddle');

Initialization

const twiddle = new NodeTwiddle(n, m);

where n is total number of objects, m is number of objects in each combination.

Generate and return all combinations

twiddle.genAllCombs(input)

where input is an optional parameter for array of n objects. Hence, output is all combination of m out of the n objects. If the input is not given, output is an array of all sequences of 0's and 1's containing m 1's.

Iterate each combination

Initialize parameters for iterating

const params = twiddle.init(input)

The input parameter is optional as described above.

The 1st combination is params.res. Each next combination is iterated via

twiddle.iterate(params)

If it returns undefined, the iteration ends.

Keywords

twiddle

FAQs

Package last updated on 20 Feb 2017

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