obliterator
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -13,5 +13,9 @@ /** | ||
filter: require('./filter.js'), | ||
forEach: require('./foreach.js'), | ||
map: require('./map.js'), | ||
match: require('./match.js'), | ||
permutations: require('./permutations.js'), | ||
powerSet: require('./power-set.js') | ||
powerSet: require('./power-set.js'), | ||
range: require('./range.js'), | ||
split: require('./split.js') | ||
}; |
{ | ||
"name": "obliterator", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Higher order iterator library for JavaScript.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -27,5 +27,8 @@ [![Build Status](https://travis-ci.org/Yomguithereal/obliterator.svg)](https://travis-ci.org/Yomguithereal/obliterator) | ||
* [filter](#filter) | ||
* [forEach](#foreach) | ||
* [map](#map) | ||
* [match](#match) | ||
* [permutations](#permutations) | ||
* [powerSet](#powerSet) | ||
* [split](#split) | ||
@@ -130,2 +133,18 @@ ## Iterator | ||
## forEach | ||
Helper function that can be used to iterate easily over the given iterator. | ||
```js | ||
import forEach from 'obliterator/foreach'; | ||
// Or | ||
import {forEach} from 'obliterator'; | ||
const set = new Set(['apple', 'banana']); | ||
forEach(set.values(), (value, i) => { | ||
console.log(i, value); | ||
}); | ||
``` | ||
## map | ||
@@ -152,2 +171,19 @@ | ||
## match | ||
Function returning an iterator over the matches of a given regex applied to the target string. | ||
```js | ||
import match from 'obliterator/match'; | ||
// Or | ||
import {match} from 'obliterator'; | ||
const iterator = match(/t/, 'test'); | ||
iterator.next().value.index | ||
>>> 0 | ||
iterator.next().value.index | ||
>>> 3 | ||
``` | ||
## permutations | ||
@@ -196,2 +232,19 @@ | ||
## split | ||
Returns an iterator over the splits of the target string, according to the given RegExp pattern. | ||
```js | ||
import split from 'obliterator/split'; | ||
// Or | ||
import {split} from 'obliterator'; | ||
const iterator = split(/;/g, 'hello;world;super'); | ||
iterator.next().value; | ||
>>> 'hello' | ||
iterator.next().value; | ||
>>> 'world' | ||
``` | ||
# Contribution | ||
@@ -198,0 +251,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19953
16
511
265