-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
32 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const IterArray = require('iterarray') | ||
|
||
module.exports = function drop (iterable, n = 1) { | ||
return this(IterArray(iterable).slice(n, Infinity)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
const findEntry = require('./findEntry') | ||
const slice = require('../gen/slice') | ||
const IterArray = require('iterarray') | ||
const sameValueZero = require('../core/same-value-zero') | ||
|
||
module.exports = function includes (iterable, e, fromIndex = 0) { | ||
const sliceIterable = slice(iterable, fromIndex) | ||
return !!findEntry(sliceIterable, value => sameValueZero(value, e)) | ||
const slicedIterable = IterArray(iterable).slice(fromIndex, Infinity) | ||
return !!findEntry(slicedIterable, value => sameValueZero(value, e)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
const findIndex = require('./findIndex') | ||
const slice = require('../gen/slice') | ||
const IterArray = require('iterarray') | ||
|
||
module.exports = function indexOf (iterable, e, fromIndex = 0) { | ||
const sliceIterable = slice(iterable, fromIndex) | ||
const index = findIndex(sliceIterable, value => value === e) | ||
const slicedIterable = IterArray(iterable).slice(fromIndex, Infinity) | ||
const index = findIndex(slicedIterable, value => value === e) | ||
return index === -1 ? -1 : fromIndex + index | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const IterArray = require('iterarray') | ||
|
||
module.exports = function slice (iterable, start = 0, end = Infinity) { | ||
return IterArray(iterable).slice(start, end) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const IterArray = require('iterarray') | ||
|
||
module.exports = function take (iterable, n = 1) { | ||
return this(IterArray(iterable).slice(0, n)) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,5 @@ | ||
module.exports = function* slice (iterable, start = 0, end = Infinity) { | ||
if (start >= end) { | ||
return | ||
} | ||
let index | ||
const iterator = iterable[Symbol.iterator]() | ||
for (index = 0; index < end; ++index) { | ||
const state = iterator.next() | ||
if (state.done) { | ||
return | ||
} else if (index >= start) { | ||
yield state.value | ||
} | ||
} | ||
const IterArray = require('iterarray') | ||
|
||
module.exports = function slice (iterable, start = 0, end = Infinity) { | ||
return this(IterArray(iterable).slice(start, end)) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters