Add url-safe-base64 npm module declarations (#25418)

* feat(types): add url-safe-base64 npm module declarations

* chore: fix name and URL
This commit is contained in:
John Wright
2018-05-01 09:10:15 -07:00
committed by Andy
parent 78b9e35d82
commit a51d27f792
4 changed files with 54 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
// Type definitions for url-safe-base64 1.1
// Project: https://github.com/commenthol/url-safe-base64#readme
// Definitions by: John Wright <https://github.com/johngeorgewright>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export function decode(safe: string): string;
export function encode(base64: string): string;
export function isBase64(string: string): string;
export function isUrlSafeBase64(string: string): string;
export function trim(string: string): string;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"strictFunctionTypes": true
},
"files": [
"index.d.ts",
"url-safe-base64-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,16 @@
import { decode, encode, isBase64, isUrlSafeBase64, trim } from 'url-safe-base64';
const safe = encode('A/B+C==');
// > 'A-B_C..'
trim(safe);
// > 'A-B_C'
const base64 = decode(safe);
// > 'A/B+C=='
isBase64(base64);
// > true
isBase64(safe);
// > false
isUrlSafeBase64(base64);
// > false
isUrlSafeBase64(safe);
// > true