-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a95dcdf
commit 336f223
Showing
9 changed files
with
72 additions
and
91 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,31 +1,25 @@ | ||
import catNamesJson = require('./cat-names.json'); | ||
/** | ||
Top 100 cat names in alphabetical order. | ||
declare const catNames: { | ||
/** | ||
Top 100 cat names in alphabetical order. | ||
@example | ||
``` | ||
import {catNames} from 'cat-names'; | ||
@example | ||
``` | ||
import catNames = require('cat-names'); | ||
catNames; | ||
//=> ['Abby', 'Angel', …] | ||
``` | ||
*/ | ||
export const catNames: readonly string[]; | ||
|
||
catNames.all; | ||
//=> ['Abby', 'Angel', …] | ||
``` | ||
*/ | ||
readonly all: Readonly<typeof catNamesJson>; | ||
/** | ||
Get a random cat name. | ||
/** | ||
Random cat name. | ||
@example | ||
``` | ||
import {randomCatName} from 'cat-names'; | ||
@example | ||
``` | ||
import catNames = require('cat-names'); | ||
catNames.random(); | ||
//=> 'Max' | ||
``` | ||
*/ | ||
random(): string; | ||
}; | ||
|
||
export = catNames; | ||
randomCatName(); | ||
//=> 'Max' | ||
``` | ||
*/ | ||
export function randomCatName(): 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,6 +1,6 @@ | ||
'use strict'; | ||
const uniqueRandomArray = require('unique-random-array'); | ||
const catNames = require('./cat-names.json'); | ||
import uniqueRandomArray from 'unique-random-array'; | ||
import catNames from './cat-names.json' with {type: 'json'}; | ||
|
||
exports.all = catNames; | ||
exports.random = uniqueRandomArray(catNames); | ||
export {catNames}; | ||
|
||
export const randomCatName = uniqueRandomArray(catNames); |
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,5 +1,5 @@ | ||
import {expectType} from 'tsd'; | ||
import catNames = require('.'); | ||
import {catNames, randomCatName} from './index.js'; | ||
|
||
expectType<readonly string[]>(catNames.all); | ||
expectType<string>(catNames.random()); | ||
expectType<readonly string[]>(catNames); | ||
expectType<string>(randomCatName()); |
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,6 @@ | ||
MIT License | ||
|
||
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com) | ||
Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
|
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 |
---|---|---|
|
@@ -4,17 +4,25 @@ | |
"description": "Get popular cat names", | ||
"license": "MIT", | ||
"repository": "sindresorhus/cat-names", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "[email protected]", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"bin": "cli.js", | ||
"type": "module", | ||
"bin": "./cli.js", | ||
"exports": { | ||
"types": "./index.d.ts", | ||
"default": "./index.js" | ||
}, | ||
"sideEffects": false, | ||
"engines": { | ||
"node": ">=8" | ||
"node": ">=18.20" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd" | ||
"//test": "xo && ava && tsd", | ||
"test": "ava && tsd" | ||
}, | ||
"files": [ | ||
"index.js", | ||
|
@@ -42,22 +50,12 @@ | |
"male" | ||
], | ||
"dependencies": { | ||
"meow": "^6.1.1", | ||
"unique-random-array": "^2.0.0" | ||
"meow": "^13.2.0", | ||
"unique-random-array": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
}, | ||
"tsd": { | ||
"compilerOptions": { | ||
"resolveJsonModule": true | ||
} | ||
}, | ||
"xo": { | ||
"rules": { | ||
"import/extensions": "off" | ||
} | ||
"ava": "^6.1.2", | ||
"tsd": "^0.31.0", | ||
"xo": "^0.58.0" | ||
} | ||
} |
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,10 +1,10 @@ | ||
import test from 'ava'; | ||
import catNames from '.'; | ||
import {catNames, randomCatName} from './index.js'; | ||
|
||
test('main', t => { | ||
t.true(catNames.all.length > 0); | ||
t.truthy(catNames.random()); | ||
t.not(catNames.random(), catNames.random()); | ||
t.is(catNames.all[0], 'Abby'); | ||
t.is(catNames.all[1], 'Angel'); | ||
t.true(catNames.length > 0); | ||
t.truthy(randomCatName()); | ||
t.not(randomCatName(), randomCatName()); | ||
t.is(catNames[0], 'Abby'); | ||
t.is(catNames[1], 'Angel'); | ||
}); |