Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce iteration support to the Maps in the module
- Loading branch information
1 parent
93c9df1
commit 763f0c9
Showing
45 changed files
with
24,904 additions
and
1,777 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 |
---|---|---|
|
@@ -28,7 +28,8 @@ | |
"plugin:jest/recommended" | ||
], | ||
"env": { | ||
"mocha": true | ||
"mocha": true, | ||
"node": true | ||
} | ||
} | ||
] | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* eslint-env mocha */ | ||
import expect from 'expect'; | ||
import iterationDecorator from '../../../src/util/iterationDecorator'; | ||
|
||
describe('iterationDecorator', function () { | ||
describe('should add a Symbol.iterator property to a collection', function () { | ||
it('should return the values when iterated', function () { | ||
// const collection = {a: 'apple', b: 'banana', c: 'cantaloupe'}; | ||
const collection = { | ||
'a': 'apple', | ||
'b': 'banana', | ||
'c': 'cantaloupe', | ||
}; | ||
const arr = ['apple', 'banana', 'cantaloupe']; | ||
const iter = iterationDecorator(collection, Object.values(collection)); | ||
expect([...iter]).toEqual(expect.arrayContaining(arr)); | ||
}); | ||
}); | ||
describe('when Symbol is not defined in the global space', function () { | ||
beforeEach(function () { | ||
global.originalSymbol = global.Symbol | ||
global.originalSymbolIterator = global.Symbol.iterator; | ||
global.Symbol = undefined; | ||
}); | ||
it('should not add a Symbol.iterator property to a collection', function () { | ||
const collection = { | ||
'a': 'apple', | ||
'b': 'banana', | ||
'c': 'cantaloupe', | ||
}; | ||
const iter = iterationDecorator(collection, []); | ||
expect(iter[global.originalSymbolIterator]).not.toBeDefined(); | ||
}); | ||
afterEach(function () { | ||
global.Symbol = global.originalSymbol; | ||
global.originalSymbol = undefined; | ||
global.originalSymbolIterator = undefined; | ||
}); | ||
}); | ||
describe('when Symbol.iterator is not defined in the global space', function () { | ||
beforeEach(function () { | ||
global.originalSymbol = global.Symbol | ||
global.originalSymbolIterator = global.Symbol.iterator; | ||
global.Symbol = function () {}; | ||
}); | ||
it('should not add a Symbol.iterator property to a collection', function () { | ||
const collection = { | ||
'a': 'apple', | ||
'b': 'banana', | ||
'c': 'cantaloupe', | ||
}; | ||
const iter = iterationDecorator(collection, []); | ||
expect(iter[global.originalSymbolIterator]).not.toBeDefined(); | ||
}); | ||
afterEach(function () { | ||
global.Symbol = global.originalSymbol; | ||
global.originalSymbol = undefined; | ||
global.originalSymbolIterator = undefined; | ||
}); | ||
}); | ||
}); |
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,13 @@ | ||
/* eslint-env mocha */ | ||
import expect from 'expect'; | ||
import iteratorProxy from '../../../src/util/iteratorProxy'; | ||
|
||
describe('iteratorProxy', function () { | ||
it('should create an iterator for the bound array', function () { | ||
const arr = ['a', 'b', 'c']; | ||
const iter = { | ||
[Symbol.iterator]: iteratorProxy.bind(arr) | ||
}; | ||
expect([...iter]).toEqual(expect.arrayContaining(arr)); | ||
}); | ||
}); |
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,97 @@ | ||
// flow-typed signature: faee240f2d5ef277c6da759bb5a2e5ec | ||
// flow-typed version: <<STUB>>/@babel/cli_v^7.18.10/flow_v0.185.2 | ||
|
||
/** | ||
* This is an autogenerated libdef stub for: | ||
* | ||
* '@babel/cli' | ||
* | ||
* Fill this stub out by replacing all the `any` types. | ||
* | ||
* Once filled out, we encourage you to share your work with the | ||
* community by sending a pull request to: | ||
* https://github.com/flowtype/flow-typed | ||
*/ | ||
|
||
declare module '@babel/cli' { | ||
declare module.exports: any; | ||
} | ||
|
||
/** | ||
* We include stubs for each file inside this npm package in case you need to | ||
* require those files directly. Feel free to delete any files that aren't | ||
* needed. | ||
*/ | ||
declare module '@babel/cli/bin/babel-external-helpers' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module '@babel/cli/bin/babel' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module '@babel/cli/lib/babel-external-helpers' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module '@babel/cli/lib/babel/dir' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module '@babel/cli/lib/babel/file' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module '@babel/cli/lib/babel' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module '@babel/cli/lib/babel/options' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module '@babel/cli/lib/babel/util' { | ||
declare module.exports: any; | ||
} | ||
|
||
declare module '@babel/cli/lib/babel/watcher' { | ||
declare module.exports: any; | ||
} | ||
|
||
// Filename aliases | ||
declare module '@babel/cli/bin/babel-external-helpers.js' { | ||
declare module.exports: $Exports<'@babel/cli/bin/babel-external-helpers'>; | ||
} | ||
declare module '@babel/cli/bin/babel.js' { | ||
declare module.exports: $Exports<'@babel/cli/bin/babel'>; | ||
} | ||
declare module '@babel/cli/index' { | ||
declare module.exports: $Exports<'@babel/cli'>; | ||
} | ||
declare module '@babel/cli/index.js' { | ||
declare module.exports: $Exports<'@babel/cli'>; | ||
} | ||
declare module '@babel/cli/lib/babel-external-helpers.js' { | ||
declare module.exports: $Exports<'@babel/cli/lib/babel-external-helpers'>; | ||
} | ||
declare module '@babel/cli/lib/babel/dir.js' { | ||
declare module.exports: $Exports<'@babel/cli/lib/babel/dir'>; | ||
} | ||
declare module '@babel/cli/lib/babel/file.js' { | ||
declare module.exports: $Exports<'@babel/cli/lib/babel/file'>; | ||
} | ||
declare module '@babel/cli/lib/babel/index' { | ||
declare module.exports: $Exports<'@babel/cli/lib/babel'>; | ||
} | ||
declare module '@babel/cli/lib/babel/index.js' { | ||
declare module.exports: $Exports<'@babel/cli/lib/babel'>; | ||
} | ||
declare module '@babel/cli/lib/babel/options.js' { | ||
declare module.exports: $Exports<'@babel/cli/lib/babel/options'>; | ||
} | ||
declare module '@babel/cli/lib/babel/util.js' { | ||
declare module.exports: $Exports<'@babel/cli/lib/babel/util'>; | ||
} | ||
declare module '@babel/cli/lib/babel/watcher.js' { | ||
declare module.exports: $Exports<'@babel/cli/lib/babel/watcher'>; | ||
} |
Oops, something went wrong.