DefinitelyTyped/types/hashids/hashids-tests.ts
Travis Sturzl 73a64f4aba [hashids] Use class instead of interface (#15920)
* Use class instead of interface

Allows hashids to be used as a type in a property `public hasher: Hashids;` and as a class `this.hasher = new Hashids()`;

* modify tests

* No need for module declaration

* modify tests
2017-04-26 15:09:45 -07:00

20 lines
494 B
TypeScript

/* require hashids */
import Hashids from 'hashids';
/* creating class object */
var hashids = new Hashids("this is my salt");
/* encoding several numbers into one id */
var id = hashids.encode(1337, 5, 77, 12345678);
id = hashids.encode(1337);
id = hashids.encode(45, 434, 1313, 99);
/* decoding that id */
var numbers = hashids.decode(id);
numbers.length > 0 ? true : false;
hashids = new Hashids("this is my salt", 0, "abcdefgh123456789");
hashids = new Hashids("this is my salt", 8);