atriusmaps-node-sdk
Version:
This project provides an API to Atrius Personal Wayfinder maps within a Node environment. See the README.md for more information
36 lines (32 loc) • 785 B
JavaScript
;
require('ramda');
require('zousan');
let lastFn = null;
const singleFile = (fn) => function(...args) {
if (lastFn) {
lastFn = lastFn.then(() => fn(...args));
} else {
lastFn = fn(...args);
}
return lastFn;
};
function filterOb(fn, ob) {
const ret = {};
Object.keys(ob).forEach((key) => {
if (fn(key, ob[key])) {
ret[key] = ob[key];
}
});
return ret;
}
const b64DecodeUnicode = (str) => (
// Going backwards: from bytestream, to percent-encoding, to original string.
decodeURIComponent(
atob(str).split("").map(function(c) {
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
}).join("")
)
);
exports.b64DecodeUnicode = b64DecodeUnicode;
exports.filterOb = filterOb;
exports.singleFile = singleFile;