Added js-base64 typings

- Checked compilation with commonjs & es6
- Added methods (encode, encodeURI, decode)
- Added Todo list for remaining methods
This commit is contained in:
Denis Carriere
2016-08-04 14:09:56 -04:00
parent 67b0d6c23d
commit 0de1b9fc3d
2 changed files with 64 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
/// <reference path="js-base64.d.ts" />
import { Base64 } from 'js-base64'
Base64.encode('dankogai'); // ZGFua29nYWk=
Base64.encode('小飼弾'); // 5bCP6aO85by+
Base64.encodeURI('小飼弾'); // 5bCP6aO85by-
Base64.decode('ZGFua29nYWk='); // dankogai
Base64.decode('5bCP6aO85by+'); // 小飼弾
// note .decodeURI() is unnecessary since it accepts both flavors
Base64.decode('5bCP6aO85by-'); // 小飼弾
+52
View File
@@ -0,0 +1,52 @@
// Type definitions for js-base64 v2.1.9
// Project: https://github.com/dankogai/js-base64
// Definitions by: Denis Carriere <https://github.com/DenisCarriere>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
## TODO
add methods:
- [x] encode
- [x] encodeURI
- [x] decode
- [ ] atob
- [ ] btoa
- [ ] fromBase64
- [ ] toBase64
- [ ] utob
- [ ] btou
- [ ] noConflict
*/
interface Base64 {
/**
* .encode
* @param {String} string
* @return {String}
*/
encode(base64: string): string;
/**
* .encodeURI
* @param {String} string
* @return {String}
*/
encodeURI(base64: string): string
/**
* .decode
* @param {String} string
* @return {String}
*/
decode(base64: string): string
/**
* Library version
*/
VERSION:string
}
declare module 'js-base64' {
const Base64: Base64
}