@nicktomlin/frequencies
v1.0.0
Published
A javscript port of clojure.core/frequencies
Downloads
3
Readme
frequencies
A javscript port of clojure.core/frequencies
Installation
$ npm install --save @nicktomlin/frequencies
Usage
const assert = require('assert')
const frequencies = require('@nicktomlin/frequencies');
// works with strings (splitting on '')
assert.deepEqual(frequencies('EEeek!'), { '!': 1, e: 4, k: 1 })
assert.deepEqual(frequencies('EE ee k!'), { '!': 1, e: 4, k: 1 })
// works with arrays
assert.deepEqual(
frequencies(['three', 'three', 'two', 'two', 'one', 'three']),
{ three: 3, two: 2, one: 1 }
)
License
MIT © Nick Tomlin