https://github.com/abranhe/permutated
πβ―πππππΆπβ―πΉ: get all available combinations
https://github.com/abranhe/permutated
node-module npm permutation
Last synced: about 1 year ago
JSON representation
πβ―πππππΆπβ―πΉ: get all available combinations
- Host: GitHub
- URL: https://github.com/abranhe/permutated
- Owner: abranhe
- License: mit
- Created: 2018-07-27T06:31:58.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-10-01T14:44:22.000Z (over 6 years ago)
- Last Synced: 2025-01-10T23:35:05.447Z (about 1 year ago)
- Topics: node-module, npm, permutation
- Language: JavaScript
- Homepage: https://p.abranhe.com/permutated/
- Size: 11.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/funding.yml
- License: license
Awesome Lists containing this project
README
# πβ―πππππΆπβ―πΉ
> Get all available combinations
[](https://travis-ci.org/abranhe/permutated)
[](https://github.com/abranhe)
[](https://cash.me/$abranhe)
[](https://patreon.com/abranhe)
[](https://github.com/abranhe/permutated/blob/master/license)
[](https://npmjs.com/package/permutated)
In mathematics, permutation is the act of arranging the members of a set into a sequence or order, or, if the set is already ordered, rearranging (reordering) its elements a process called permuting. Permutations differ from combinations, which are selections of some members of a set regardless of order.
[Read More...](https://en.wikipedia.org/wiki/Permutation)
### Complexity?
7 letters word ~> [7!](https://www.google.com/search?q=7!) ~> 5040 available combinations to generate.
## Important
This module uses [Array.prototype.flat()](https://node.green/#ES2019-features-Array-prototype--flat--flatMap--Array-prototype-flat) that was introduced on Node.js 11+. You can still use the previus version [(1.0.1)](https://www.npmjs.com/package/permutated/v/1.0.1) of permutated.
## Install
```
$ npm install permutated
```
## Usage
```js
const permutated = require('permutated');
permutated('abc'));
//=> [ 'abc', 'acb', 'bac', 'bca', 'cab', 'cba' ]
permutated.numberOfPermutations('1234567'));
//=> 5040
```
## API
### permutated(word)
Return type: `string[] | string`
Return all the permuations available from a string.
#### word
Type: `string`
The string to permutate.
### numberOfPermutations(word)
Return Type: `number`
Get the number of permuations avilable in a string.
#### word
Type: `string`
The string to permutate.
## Related
- [all-words](https://github.com/abranhe/all-words): Generate all available words super fast
## License
MIT Β© [Carlos Abraham](https://abranhe.com)