-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start using native ArrayIterators which use native array functions
- switch to babel.config.cjs instead of .babelrc - update dependencies
- Loading branch information
1 parent
b36f53d
commit acb1a20
Showing
21 changed files
with
1,289 additions
and
1,328 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module.exports = function (api) { | ||
api.cache(true); | ||
api.retainLines = true; | ||
const presets = [ '@babel/preset-env' ]; | ||
const plugins = [ | ||
[ | ||
"module-resolver", | ||
{ | ||
"alias": { | ||
"modern-linq": "./index.esm.js" | ||
} | ||
} | ||
], | ||
[ | ||
"@babel/plugin-proposal-private-methods", | ||
{ "loose": true } | ||
] | ||
]; | ||
return { | ||
presets, | ||
plugins | ||
} | ||
}; |
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
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
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
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
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,31 @@ | ||
import {doneValue, getIterator, iteratorResultCreator} from "../../utils"; | ||
|
||
export default class ArrayLikeIterable { | ||
constructor(source) { | ||
this.source = source; | ||
} | ||
|
||
get() { | ||
return Array.isArray(this.source) ? this.source : this; | ||
} | ||
|
||
[Symbol.iterator]() { | ||
if (Array.isArray(this.source)) { | ||
return getIterator(this.source); | ||
} | ||
const length = this.source.length; | ||
const source = this.source; | ||
let current = 0; | ||
return { | ||
next() { | ||
if (current < length) { | ||
const value = source[current]; | ||
current++; | ||
return iteratorResultCreator(value); | ||
} else { | ||
return doneValue(); | ||
} | ||
} | ||
}; | ||
} | ||
} |
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,25 @@ | ||
import {getIterator} from "../../utils"; | ||
import {ArrayFilterIterable} from "../where"; | ||
import {ToArrayArrayFinalizer} from "../../finalizers/to-array"; | ||
|
||
export default class ArrayIterable { | ||
constructor(array) { | ||
this.array = array; | ||
} | ||
|
||
[Symbol.iterator]() { | ||
return getIterator(this.array); | ||
} | ||
|
||
get() { | ||
return this.array; | ||
} | ||
|
||
where(predicate) { | ||
return new ArrayFilterIterable(this.array, predicate); | ||
} | ||
|
||
toArray(mapper) { | ||
return ToArrayArrayFinalizer.get(this, mapper); | ||
} | ||
} |
Oops, something went wrong.