Skip to content

Commit b0f0a17

Browse files
💥 refactor!: Rename fromKeys to constant.
Fixes #101. BREAKING CHANGE: API change.
1 parent 5ece008 commit b0f0a17

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ See [docs](https://iterable-iterator.github.io/mapping).
66
Parent is [js-library](https://github.com/make-github-pseudonymous-again/js-library).
77

88
```js
9-
> import { fromKeys , reflect } from '@iterable-iterator/mapping' ;
9+
> import { constant , reflect } from '@iterable-iterator/mapping' ;
1010
> import {enumerate} from '@iterable-iterator/zip';
11-
> fromKeys( 'ab' , 1 )
11+
> constant( 'ab' , 1 )
1212
[['a', 1], ['b', 1]]
1313
> reflect(enumerate('ab'))
1414
[['a', 0], ['b', 1]]

src/fromKeys.js renamed to src/constant.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
* @param {any} value
77
* @return {IterableIterator} The output mapping.
88
*/
9-
export default function* fromKeys(keys, value) {
9+
export default function* constant(keys, value) {
1010
for (const key of keys) yield [key, value];
1111
}

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export {default as fromKeys} from './fromKeys.js';
1+
export {default as constant} from './constant.js';
22
export {default as reflect} from './reflect.js';
33
export {default as toObject} from './toObject.js';

test/src/constant.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import test from 'ava';
2+
3+
import {constant} from '../../src/index.js';
4+
5+
test('constant', (t) => {
6+
t.deepEqual([...constant('', 1)], []);
7+
8+
t.deepEqual(
9+
[...constant('abcde', 1)],
10+
[
11+
['a', 1],
12+
['b', 1],
13+
['c', 1],
14+
['d', 1],
15+
['e', 1],
16+
],
17+
);
18+
});

test/src/fromKeys.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)