string-permutation
Find all permutations of a string by a given length.
Last updated 5 years ago by kchan .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install string-permutation 
SYNC missed versions from official npm registry.

string-permutation NPM version NPM downloads Build Status

Find all permutations of a string by a given length.

Install

$ npm install --save string-permutation

Usage

const permutation = require('string-permutation')

permutation('ab', 2)
//=> ['aa', 'ab', 'ba', 'bb']

permutation('ab', {maxSize: 2, recursive: true})
//=> ['a', 'b', 'aa', 'ab', 'ba', 'bb']

const alphabet = 'abcdefghijklmnopqrstuvwxyz'
permutation(alphabet, 2)
/**
[
  'aa',
  'ab',
  'ac',
  ...
  'zx',
  'zy',
  'zz'
]
*/

API

stringPermutation(input, [options])

input

Type: string

The allowed characters.

options

Type: number object

When it's a number we treat it as the options.maxSize

maxSize

The size of each item in the result.

recursive

Including the items whose length is smaller than maxSize.

License

MIT © EGOIST

Current Tags

  • 0.1.0                                ...           latest (5 years ago)

1 Versions

  • 0.1.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (2)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |