Releases: desnor/itrabble
v2 release candidate 2
Version 2 seeks to update several things about itrabble
:
Instantiation via of
and from
Two new functions have been provided for instantiating an itrabble
of
from
import { from, of } from 'itrabble'
const itrabbleFromArray = from([1, 2, 3, 4, 5])
itrabbleFromArray.takeWhile(x => x < 3).last() // => itrabble sequence of 2
const itrabbleOfNumbers = of(1, 2, 3, 4, 5)
itrabbleOfNumbers.takeWhile(x => x < 3).last() // => itrabble sequence of 2
Adding pipe
-ability
This involves separating out the operators into functions that can be imported individually and called in a lettable style, through the new pipe
method.
For example:
import { from, filter, take } from 'itrabble'
const itrabbleNums = from([1, 2, 3, 4, 5]) // alternatively as of(1, 2, 3, 4, 5)
const [three, four] = itrabbleNums.pipe(
filter(x => x > 2),
take(2),
).toArray
console.log(three, four)
// => 3, 4
- Performance is slightly improved using this format, and potentially in the future this will be the preferred way of using the library, keeping the surface area of
itrabble
itself very slim.
Removing objectPrototypeDecorator
No more access to mutating the Object
prototype.
What's Changed
- Bump lodash from 4.17.15 to 4.17.19 by @dependabot in #11
- Update package exports paths by @desnor in #13
- Rewrite in typescript by @desnor in #27
New Contributors
- @dependabot made their first contribution in #11
Full Changelog: v2.0.0-rc.1...v2.0.0-rc.2
Add Scan Method
Added scan method to itrabble namespace. See here for Documentation
Make object modifying import opt-in, add individual function exports
v1.1.0
The main way of using the module hasn't changed, for example:
const itrabble = require('itrabble')
itrabble(array).skipUntil(x => x === 'd')
// => iterable sequence { d e f }
However if you were previously using the following syntax:
require('itrabble')
array.itrabble.skipUntil(x => x === 'd')
This has been updated to:
require('itrabble/lib/object-prototype-decorator')
array.itrabble.skipUntil(x => x === 'd')
As the name suggests more clearly now, this does modify the Object prototype. It's unlikely that the property itrabble
will clash with any existing namespace, but it's good to be aware of what this is doing if you are going to use it.
Individual Exports
itrabble
now provides a way to access the individual methods as separate exports which can be imported on a per-use basis, unattached to the rest of the itrabble
module.
An ideal way to use this would be with the (somewhat) proposed bind operator ::
. The proposal is on Github, and there is a Babel transform for this which describes the idea well. It hasn't progressed past stage 0 and seems to have lost momentum, so while it's probably not appropriate for production code I really like it. For example:
import take from 'itrabble/lib/take'
const array = ['a','b','c']
const firstTwo = array::take(2)
// => iterable sequence { a b }