ympc-utils
Utility functions used throughout YOMYPOPCORN apps.
Installation
npm install ympc-utils --save
API
var utils = ;
str = utils.padTime(time)
Left-pads a timestamp with '0's and returns a 16-character string;
utils;// '0001438304724009'
utils.cb(callback [, ...arguments])
A callback helper for optional callbacks. Only calls callback
with
arguments
if callback
is actually a function.
{ ;} ;
int = utils.sien(season, episode)
Creates a season-independent episode number by multiplying the season number by 1000 and adding it to the episode number. It assumes that a show has never more than 999 episodes per season. fingers crossed
Season 1, Episode 22 becomes 1022.
utils;// 1022
object = utils.removeNonScalars(obj)
Returns a new object that has all non-scalar properties removed.
var myObj = heeey: 'hooo' yolo: true feet: left: 2 right: 0 { return 'weeeeee'; }; utils;// { heeey: 'hooo', yolo: true }
string = utils.generateUserToken(secret, username)
Returns a hex-encoded SHA1 hash of username
and secret
.
utils;// '4df9d4f8adcd0736'
boolean = utils.validateUserToken(secret, username, token)
Validates a token generated by utils.generateUserToken()
.
utils;// true
License
MIT