Skip to content

Commit f432cee

Browse files
committed
Merge pull request DefinitelyTyped#4475 from tkrotoff/master
Type definitions for urlsafe-base64 v1.0.0
2 parents 6dba84e + 23b92b8 commit f432cee

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference path="urlsafe-base64.d.ts" />
2+
3+
import URLSafeBase64 = require('urlsafe-base64');
4+
5+
var base64 = URLSafeBase64.encode(new Buffer('3Rpbmd1aXNoZWQ', 'base64'));
6+
7+
var buf = URLSafeBase64.decode('3Rpbmd1aXNoZWQ');
8+
9+
var isValid = URLSafeBase64.validate('3Rpbmd1aXNoZWQ');

urlsafe-base64/urlsafe-base64.d.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Type definitions for urlsafe-base64 v1.0.0
2+
// Project: https://github.com/RGBboy/urlsafe-base64
3+
// Definitions by: Tanguy Krotoff <https://github.com/tkrotoff>
4+
// Definitions: https://github.com/borisyankov/DefinitelyTyped
5+
6+
/// <reference path="../node/node.d.ts"/>
7+
8+
declare module 'urlsafe-base64' {
9+
/**
10+
* Library version.
11+
*/
12+
export var version: string;
13+
14+
/**
15+
* .encode
16+
*
17+
* return an encoded Buffer as URL Safe Base64
18+
*
19+
* Note: This function encodes to the RFC 4648 Spec where '+' is encoded
20+
* as '-' and '/' is encoded as '_'. The padding character '=' is
21+
* removed.
22+
*
23+
* @param {Buffer} buffer
24+
* @return {String}
25+
* @api public
26+
*/
27+
export function encode(buffer: Buffer): string;
28+
29+
/**
30+
* .decode
31+
*
32+
* return an decoded URL Safe Base64 as Buffer
33+
*
34+
* @param {String}
35+
* @return {Buffer}
36+
* @api public
37+
*/
38+
export function decode(base64: string): Buffer;
39+
40+
/**
41+
* .validate
42+
*
43+
* Validates a string if it is URL Safe Base64 encoded.
44+
*
45+
* @param {String}
46+
* @return {Boolean}
47+
* @api public
48+
*/
49+
export function validate(base64: string): boolean;
50+
}

0 commit comments

Comments
 (0)