-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require Node.js 12.20 and move to ESM
- Loading branch information
1 parent
28c4d17
commit 6013e5f
Showing
8 changed files
with
24 additions
and
33 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
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,6 +1,4 @@ | ||
'use strict'; | ||
|
||
module.exports = object => { | ||
export default function randomObjectKey(object) { | ||
const keys = Object.keys(object); | ||
return keys[Math.floor(Math.random() * keys.length)]; | ||
}; | ||
} |
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,4 +1,4 @@ | ||
import {expectType} from 'tsd'; | ||
import randomObjKey = require('.'); | ||
import randomObjectKey from './index.js'; | ||
|
||
expectType<'foo' | 'bar'>(randomObjKey({foo: true, bar: true})); | ||
expectType<'foo' | 'bar'>(randomObjectKey({foo: true, bar: true})); |
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 |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import test from 'ava'; | ||
import stableFn from 'stable-fn'; | ||
import randomObjectKey from '.'; | ||
import stableFunction from 'stable-fn'; | ||
import randomObjectKey from './index.js'; | ||
|
||
const fixture = { | ||
a: true, | ||
b: true, | ||
c: true, | ||
d: true, | ||
e: true | ||
e: true, | ||
}; | ||
|
||
test('main', t => { | ||
t.false(stableFn(() => randomObjectKey(fixture))); | ||
t.false(stableFunction(() => randomObjectKey(fixture))); | ||
|
||
for (let i = 0; i < 1000; i++) { | ||
for (let index = 0; index < 1000; index++) { | ||
t.is(typeof randomObjectKey(fixture), 'string'); | ||
} | ||
}); |