-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: this changes the min Node.js version and changes the API
- Loading branch information
1 parent
9d5a1d6
commit 1598d68
Showing
17 changed files
with
16,290 additions
and
17,346 deletions.
There are no files selected for viewing
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
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,5 @@ | ||
{ | ||
"singleQuote": true, | ||
"semi": false, | ||
"trailingComma": "none" | ||
} |
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,9 +1,4 @@ | ||
#!/usr/bin/env node | ||
const { randomWords } = require("./index"); | ||
import { randomWords } from './index.js' | ||
|
||
const cli = async () => { | ||
const words = await randomWords(); | ||
process.stdout.write(words.join(" ")); | ||
}; | ||
|
||
cli(); | ||
process.stdout.write(randomWords().join(' ')) |
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 @@ | ||
module.exports = { extends: ['@commitlint/config-conventional'] } |
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,3 +1,3 @@ | ||
const { randomWords } = require("@nordicsemiconductor/random-words"); | ||
import { randomWords } from '@nordicsemiconductor/random-words' | ||
|
||
randomWords().then(console.log); | ||
console.log(randomWords()) |
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 @@ | ||
/** | ||
* Generate random words | ||
*/ | ||
export declare const randomWords: (params?: { | ||
numWords: number; | ||
}) => Promise<string[]>; | ||
export declare const randomWords: (params?: { numWords: number }) => string[] |
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,20 +1,20 @@ | ||
const { words, count } = require("./words"); | ||
const randomNumber = require("random-number-csprng"); | ||
import { words } from './words.js' | ||
import { randomInt } from 'node:crypto' | ||
|
||
async function* randomWord() { | ||
/* eslint-disable generator-star-spacing */ | ||
/* eslint-disable space-before-function-paren */ | ||
function* randomWord() { | ||
while (true) { | ||
const number = await randomNumber(0, count - 1); | ||
yield words[number]; | ||
const number = randomInt(0, words.length - 1) | ||
yield words[number] | ||
} | ||
} | ||
|
||
module.exports = { | ||
randomWords: async ({ numWords } = { numWords: 4 }) => { | ||
const randomWords = []; | ||
const r = randomWord(); | ||
for (let i = 0; i < parseInt(numWords, 10); i++) { | ||
randomWords.push((await r.next()).value); | ||
} | ||
return randomWords; | ||
}, | ||
}; | ||
export const randomWords = ({ numWords } = { numWords: 4 }) => { | ||
const randomWords = [] | ||
const r = randomWord() | ||
for (let i = 0; i < parseInt(numWords, 10); i++) { | ||
randomWords.push(r.next().value) | ||
} | ||
return randomWords | ||
} |
Oops, something went wrong.