Add package nanoid (#22852)

This commit is contained in:
Ruben Schmidmeister
2018-01-12 10:02:48 -08:00
committed by Ryan Cavanaugh
parent a2f0dc2938
commit 5be99ed666
9 changed files with 71 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
declare function format(random: (bytes: number) => number[], alphabet: string, size: number): string;
export = format;
+3
View File
@@ -0,0 +1,3 @@
declare function generate(alphabet: string, size: number): string;
export = generate;
+8
View File
@@ -0,0 +1,8 @@
// Type definitions for nanoid 1.0
// Project: https://github.com/ai/nanoid
// Definitions by: Ruben Schmidmeister <https://github.com/bash>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function nanoid(size?: number): string;
export = nanoid;
+17
View File
@@ -0,0 +1,17 @@
import nanoid = require('nanoid');
import format = require('nanoid/format');
import generate = require('nanoid/generate');
import random = require('nanoid/random');
import randomBrowser = require('nanoid/random-browser');
import url = require('nanoid/url');
const _random = (size: number) => [1, 2, 3, 4];
nanoid();
nanoid(10);
format(_random, "abcdef", 5);
generate('0123456789абвгдеё', 5);
random(10);
randomBrowser(10);
console.log(url);
+3
View File
@@ -0,0 +1,3 @@
declare function randomBrowser(bytes: number): Uint8Array;
export = randomBrowser;
+5
View File
@@ -0,0 +1,5 @@
/// <reference types="node" />
import crypto = require('crypto');
export = crypto.randomBytes;
+28
View File
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"strictFunctionTypes": true
},
"files": [
"format.d.ts",
"generate.d.ts",
"index.d.ts",
"nanoid-tests.ts",
"random-browser.d.ts",
"random.d.ts",
"url.d.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+3
View File
@@ -0,0 +1,3 @@
declare var url: string;
export = url;