Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@naturalcycles/js-lib

Package Overview
Dependencies
Maintainers
4
Versions
525
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@naturalcycles/js-lib - npm Package Compare versions

Comparing version 1.0.77 to 1.0.79

44

dist-esm/decorators/memo.decorator.js

@@ -5,10 +5,3 @@ // Based on:

// http://inlehmansterms.net/2015/03/01/javascript-memoization/
/* tslint:disable:no-invalid-this */
var jsonCacheKey = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return JSON.stringify(args);
};
const jsonCacheKey = (...args) => JSON.stringify(args);
/**

@@ -19,26 +12,35 @@ * Memoizes the method of the class, so it caches the output and returns the cached version if the "key"

* There is more advanced version of memo decorator called `memoCache`.
*
* Supports dropping it's cache by calling .dropCache() method of decorated function (useful in unit testing).
*/
export var memo = function () { return function (target, key, descriptor) {
export const memo = () => (target, key, descriptor) => {
if (typeof descriptor.value !== 'function') {
throw new Error('Memoization can be applied only to methods');
}
var originalFn = descriptor.value;
var cache = new Map();
descriptor.value = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var cacheKey = jsonCacheKey(args);
const originalFn = descriptor.value;
const cache = new Map();
let loggingEnabled = false;
descriptor.value = function (...args) {
const cacheKey = jsonCacheKey(args);
if (cache.has(cacheKey)) {
var cached = cache.get(cacheKey);
// console.log('returning value from cache: ', cacheKey, key)
const cached = cache.get(cacheKey);
if (loggingEnabled) {
console.log(`memo (method=${key}) returning value from cache: `, cacheKey, key);
}
return cached;
}
var res = originalFn.apply(this, args);
const res = originalFn.apply(this, args);
cache.set(cacheKey, res);
return res;
};
descriptor.value.dropCache = () => {
console.log(`memo.dropCache (method=${key})`);
cache.clear();
};
descriptor.value.setLogging = (enabled = true) => {
loggingEnabled = enabled;
console.log(`memo.loggingEnabled=${enabled} (method=${key})`);
};
return descriptor;
}; };
};
//# sourceMappingURL=memo.decorator.js.map

@@ -7,42 +7,39 @@ // Based on:

import LRU from 'lru-cache';
var jsonCacheKey = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
const jsonCacheKey = (...args) => JSON.stringify(args);
export const memoCache = (opts = {}) => (target, key, descriptor) => {
if (typeof descriptor.value !== 'function') {
throw new Error('Memoization can be applied only to methods');
}
return JSON.stringify(args);
};
export var memoCache = function (opts) {
if (opts === void 0) { opts = {}; }
return function (target, key, descriptor) {
if (typeof descriptor.value !== 'function') {
throw new Error('Memoization can be applied only to methods');
const originalFn = descriptor.value;
if (!opts.cacheKeyFn)
opts.cacheKeyFn = jsonCacheKey;
const lruOpts = {
max: opts.maxSize || 100,
maxAge: opts.ttl || Infinity,
};
const cache = new LRU(lruOpts);
let loggingEnabled = false;
descriptor.value = function (...args) {
const cacheKey = opts.cacheKeyFn(args);
if (cache.has(cacheKey)) {
const cached = cache.get(cacheKey);
if (loggingEnabled) {
console.log(`memo (method=${key}) returning value from cache: `, cacheKey, key);
}
return cached;
}
var originalFn = descriptor.value;
if (!opts.cacheKeyFn)
opts.cacheKeyFn = jsonCacheKey;
var lruOpts = {
max: opts.maxSize || 100,
maxAge: opts.ttl || Infinity,
};
var cache = new LRU(lruOpts);
// descriptor.value = memoize(descriptor.value, opts.resolver)
descriptor.value = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var cacheKey = opts.cacheKeyFn(args);
if (cache.has(cacheKey)) {
var cached = cache.get(cacheKey);
// console.log('returning value from cache: ', cacheKey, key)
return cached;
}
var res = originalFn.apply(this, args);
cache.set(cacheKey, res);
return res;
};
return descriptor;
const res = originalFn.apply(this, args);
cache.set(cacheKey, res);
return res;
};
descriptor.value.dropCache = () => {
console.log(`memo.dropCache (method=${key})`);
cache.reset();
};
descriptor.value.setLogging = (enabled = true) => {
loggingEnabled = enabled;
console.log(`memo.loggingEnabled=${enabled} (method=${key})`);
};
return descriptor;
};
//# sourceMappingURL=memoCache.decorator.js.map

@@ -1,38 +0,21 @@

var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* Base class for all our (not system) errors
*/
var AppError = /** @class */ (function (_super) {
__extends(AppError, _super);
function AppError(message, data) {
var _this = _super.call(this, message) || this;
_this.data = data;
Object.defineProperty(_this, 'name', {
value: _this.constructor.name,
export class AppError extends Error {
constructor(message, data) {
super(message);
this.data = data;
Object.defineProperty(this, 'name', {
value: this.constructor.name,
});
if (Error.captureStackTrace) {
Error.captureStackTrace(_this, _this.constructor);
Error.captureStackTrace(this, this.constructor);
}
else {
Object.defineProperty(_this, 'stack', {
Object.defineProperty(this, 'stack', {
value: new Error().stack,
});
}
return _this;
}
return AppError;
}(Error));
export { AppError };
}
//# sourceMappingURL=app.error.js.map
// Source: https://github.com/substack/deep-freeze/blob/master/index.js
export function deepFreeze(o) {
Object.freeze(o);
Object.getOwnPropertyNames(o).forEach(function (prop) {
Object.getOwnPropertyNames(o).forEach(prop => {
if (o.hasOwnProperty(prop) &&

@@ -15,13 +15,13 @@ o[prop] !== null &&

export function silentConsole() {
console.log = function () { return undefined; };
console.debug = function () { return undefined; };
console.info = function () { return undefined; };
console.warn = function () { return undefined; };
console.error = function () { return undefined; };
console.time = function () { return undefined; };
console.table = function () { return undefined; };
console.log = () => undefined;
console.debug = () => undefined;
console.info = () => undefined;
console.warn = () => undefined;
console.error = () => undefined;
console.time = () => undefined;
console.table = () => undefined;
}
export function runAllTests() {
var args = process.argv.slice();
var lastArg = args.filter(function (x) { return !x.startsWith('-'); }).pop();
const args = process.argv.slice();
const lastArg = args.filter(x => !x.startsWith('-')).pop();
return ((lastArg && (lastArg.endsWith('/jest') || lastArg.endsWith('/jest-worker/build/child.js'))) ||

@@ -28,0 +28,0 @@ false);

@@ -1,23 +0,9 @@

var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var ObjectUtil = /** @class */ (function () {
function ObjectUtil() {
}
export class ObjectUtil {
// Picks just allowed fields and no other fields
// pick<T> (obj: any, fields: string[], initialObject = {}): T {
ObjectUtil.prototype.pick = function (obj, fields, initialObject) {
if (initialObject === void 0) { initialObject = {}; }
pick(obj, fields, initialObject = {}) {
if (!obj || !fields || !fields.length)
return obj;
var o = initialObject;
fields.forEach(function (k) {
const o = initialObject;
fields.forEach(k => {
if (k in obj)

@@ -27,3 +13,3 @@ o[k] = obj[k];

return o;
};
}
/**

@@ -33,21 +19,17 @@ * Does NOT mutate (unless "mutate" flag is set)

*/
ObjectUtil.prototype.filterFalsyValues = function (_obj, mutate) {
if (mutate === void 0) { mutate = false; }
return this.filterValues(_obj, function (k, v) { return !!v; }, mutate);
};
ObjectUtil.prototype.filterEmptyStringValues = function (_obj, mutate) {
if (mutate === void 0) { mutate = false; }
return this.filterValues(_obj, function (k, v) { return v !== ''; }, mutate);
};
ObjectUtil.prototype.filterUndefinedValues = function (_obj, mutate) {
if (mutate === void 0) { mutate = false; }
return this.filterValues(_obj, function (k, v) { return v !== undefined && v !== null; }, mutate);
};
ObjectUtil.prototype.filterValues = function (_obj, predicate, mutate) {
if (mutate === void 0) { mutate = false; }
filterFalsyValues(_obj, mutate = false) {
return this.filterValues(_obj, (k, v) => !!v, mutate);
}
filterEmptyStringValues(_obj, mutate = false) {
return this.filterValues(_obj, (k, v) => v !== '', mutate);
}
filterUndefinedValues(_obj, mutate = false) {
return this.filterValues(_obj, (k, v) => v !== undefined && v !== null, mutate);
}
filterValues(_obj, predicate, mutate = false) {
if (!this.isObject(_obj))
return _obj;
var o = mutate ? _obj : __assign({}, _obj);
Object.keys(o).forEach(function (k) {
var keep = predicate(k, o[k]);
const o = mutate ? _obj : Object.assign({}, _obj);
Object.keys(o).forEach(k => {
const keep = predicate(k, o[k]);
if (!keep)

@@ -57,16 +39,14 @@ delete o[k];

return o;
};
ObjectUtil.prototype.transformValues = function (_obj, transformFn, mutate) {
if (mutate === void 0) { mutate = false; }
}
transformValues(_obj, transformFn, mutate = false) {
if (!this.isObject(_obj))
return _obj;
var o = mutate ? _obj : __assign({}, _obj);
Object.keys(o).forEach(function (k) {
const o = mutate ? _obj : Object.assign({}, _obj);
Object.keys(o).forEach(k => {
o[k] = transformFn(k, o[k]);
});
return o;
};
ObjectUtil.prototype.objectNullValuesToUndefined = function (_obj, mutate) {
if (mutate === void 0) { mutate = false; }
return this.transformValues(_obj, function (k, v) {
}
objectNullValuesToUndefined(_obj, mutate = false) {
return this.transformValues(_obj, (k, v) => {
if (v === null)

@@ -76,31 +56,29 @@ return undefined;

}, mutate);
};
ObjectUtil.prototype.deepEquals = function (a, b) {
}
deepEquals(a, b) {
return JSON.stringify(this.sortObjectDeep(a)) === JSON.stringify(this.sortObjectDeep(b));
};
}
/**
* Deep copy object (by json parse/stringify).
*/
ObjectUtil.prototype.deepCopy = function (o) {
deepCopy(o) {
return JSON.parse(JSON.stringify(o));
};
ObjectUtil.prototype.isObject = function (item) {
}
isObject(item) {
return (item && typeof item === 'object' && !Array.isArray(item) && item !== null) || false;
};
ObjectUtil.prototype.isEmptyObject = function (obj) {
}
isEmptyObject(obj) {
return obj && obj.constructor === Object && Object.keys(obj).length === 0;
};
}
// from: https://gist.github.com/Salakar/1d7137de9cb8b704e48a
ObjectUtil.prototype.mergeDeep = function (target, source) {
var _this = this;
mergeDeep(target, source) {
if (this.isObject(target) && this.isObject(source)) {
Object.keys(source).forEach(function (key) {
var _a, _b;
if (_this.isObject(source[key])) {
Object.keys(source).forEach(key => {
if (this.isObject(source[key])) {
if (!target[key])
Object.assign(target, (_a = {}, _a[key] = {}, _a));
_this.mergeDeep(target[key], source[key]);
Object.assign(target, { [key]: {} });
this.mergeDeep(target[key], source[key]);
}
else {
Object.assign(target, (_b = {}, _b[key] = source[key], _b));
Object.assign(target, { [key]: source[key] });
}

@@ -110,8 +88,7 @@ });

return target;
};
}
/**
* Mutates
*/
ObjectUtil.prototype.deepTrim = function (o) {
var _this = this;
deepTrim(o) {
if (!o)

@@ -123,32 +100,31 @@ return o;

else if (typeof o === 'object') {
Object.keys(o).forEach(function (k) {
o[k] = _this.deepTrim(o[k]);
Object.keys(o).forEach(k => {
o[k] = this.deepTrim(o[k]);
});
}
return o;
};
ObjectUtil.prototype.defaultSortFn = function (a, b) {
}
defaultSortFn(a, b) {
return a.localeCompare(b);
};
}
// based on: https://github.com/IndigoUnited/js-deep-sort-object
ObjectUtil.prototype.sortObjectDeep = function (o) {
var _this = this;
sortObjectDeep(o) {
// array
if (Array.isArray(o)) {
return o.map(function (i) { return _this.sortObjectDeep(i); });
return o.map(i => this.sortObjectDeep(i));
}
if (this.isObject(o)) {
var out_1 = {};
const out = {};
Object.keys(o)
.sort(function (a, b) { return _this.defaultSortFn(a, b); })
.forEach(function (k) {
out_1[k] = _this.sortObjectDeep(o[k]);
.sort((a, b) => this.defaultSortFn(a, b))
.forEach(k => {
out[k] = this.sortObjectDeep(o[k]);
});
return out_1;
return out;
}
return o;
};
}
// from: https://github.com/jonschlinkert/unset-value
// mutates obj
ObjectUtil.prototype.unsetValue = function (obj, prop) {
unsetValue(obj, prop) {
if (!this.isObject(obj)) {

@@ -161,4 +137,4 @@ return;

}
var segs = prop.split('.');
var last = segs.pop();
const segs = prop.split('.');
let last = segs.pop();
while (segs.length && segs[segs.length - 1].slice(-1) === '\\') {

@@ -168,3 +144,3 @@ last = segs.pop().slice(0, -1) + '.' + last;

while (segs.length && this.isObject(obj)) {
var k = (prop = segs.shift());
const k = (prop = segs.shift());
obj = obj[k];

@@ -175,3 +151,3 @@ }

delete obj[last];
};
}
/**

@@ -187,49 +163,44 @@ * Returns object with filtered keys from "exclude" array.

*/
ObjectUtil.prototype.mask = function (_o, exclude, deepCopy) {
var _this = this;
if (deepCopy === void 0) { deepCopy = false; }
var o = __assign({}, _o);
mask(_o, exclude, deepCopy = false) {
let o = Object.assign({}, _o);
if (deepCopy)
o = this.deepCopy(o);
exclude.forEach(function (e) {
exclude.forEach(e => {
// eval(`delete o.${e}`)
_this.unsetValue(o, e);
this.unsetValue(o, e);
});
return o;
};
}
/**
* Turns ['a', b'] into {a: true, b: true}
*/
ObjectUtil.prototype.arrayToHash = function (a) {
if (a === void 0) { a = []; }
return a.reduce(function (o, item) {
arrayToHash(a = []) {
return a.reduce((o, item) => {
o[item] = true;
return o;
}, {});
};
ObjectUtil.prototype.classToPlain = function (obj) {
if (obj === void 0) { obj = {}; }
}
classToPlain(obj = {}) {
return JSON.parse(JSON.stringify(obj));
};
ObjectUtil.prototype.getKeyByValue = function (object, value) {
}
getKeyByValue(object, value) {
if (!this.isObject(object))
return;
return Object.keys(object).find(function (k) { return object[k] === value; });
};
ObjectUtil.prototype.invertObject = function (o) {
var inv = {};
Object.keys(o).forEach(function (k) {
return Object.keys(object).find(k => object[k] === value);
}
invertObject(o) {
const inv = {};
Object.keys(o).forEach(k => {
inv[o[k]] = k;
});
return inv;
};
ObjectUtil.prototype.invertMap = function (m) {
var inv = new Map();
m.forEach(function (v, k) { return inv.set(v, k); });
}
invertMap(m) {
const inv = new Map();
m.forEach((v, k) => inv.set(v, k));
return inv;
};
ObjectUtil.prototype.by = function (items, by) {
if (items === void 0) { items = []; }
var r = {};
items.forEach(function (item) {
}
by(items = [], by) {
const r = {};
items.forEach((item) => {
if (item[by])

@@ -239,7 +210,5 @@ r[item[by]] = item;

return r;
};
return ObjectUtil;
}());
export { ObjectUtil };
export var objectUtil = new ObjectUtil();
}
}
export const objectUtil = new ObjectUtil();
//# sourceMappingURL=object.util.js.map

@@ -1,10 +0,7 @@

var RandomSharedUtil = /** @class */ (function () {
function RandomSharedUtil() {
class RandomSharedUtil {
randomInt(minIncl, maxIncl) {
return Math.floor(Math.random() * (maxIncl - minIncl + 1) + minIncl);
}
RandomSharedUtil.prototype.randomInt = function (minIncl, maxIncl) {
return Math.floor(Math.random() * (maxIncl - minIncl + 1) + minIncl);
};
return RandomSharedUtil;
}());
export var randomSharedUtil = new RandomSharedUtil();
}
export const randomSharedUtil = new RandomSharedUtil();
//# sourceMappingURL=random.shared.util.js.map

@@ -9,51 +9,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var ScriptSharedUtil = /** @class */ (function () {
function ScriptSharedUtil() {
}
ScriptSharedUtil.prototype.loadScript = function (src, async) {
if (async === void 0) { async = true; }
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve, reject) {
var s = document.createElement('script');
s.src = src;
s.onload = resolve;
s.onerror = reject;
if (async)
s.async = true;
document.head.appendChild(s);
})];
class ScriptSharedUtil {
loadScript(src, async = true) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
const s = document.createElement('script');
s.src = src;
s.onload = resolve;
s.onerror = reject;
if (async)
s.async = true;
document.head.appendChild(s);
});
});
};
return ScriptSharedUtil;
}());
export var scriptSharedUtil = new ScriptSharedUtil();
}
}
export const scriptSharedUtil = new ScriptSharedUtil();
//# sourceMappingURL=script.shared.util.js.map

@@ -1,17 +0,13 @@

var StringSharedUtil = /** @class */ (function () {
function StringSharedUtil() {
export class StringSharedUtil {
capitalizeFirstLetter(s) {
return s.charAt(0).toUpperCase() + s.slice(1);
}
StringSharedUtil.prototype.capitalizeFirstLetter = function (s) {
return s.charAt(0).toUpperCase() + s.slice(1);
};
StringSharedUtil.prototype.lowercaseFirstLetter = function (s) {
lowercaseFirstLetter(s) {
return s.charAt(0).toLowerCase() + s.slice(1);
};
StringSharedUtil.prototype.removeWhitespace = function (s) {
}
removeWhitespace(s) {
return s.replace(/\s/g, '');
};
return StringSharedUtil;
}());
export { StringSharedUtil };
export var stringSharedUtil = new StringSharedUtil();
}
}
export const stringSharedUtil = new StringSharedUtil();
//# sourceMappingURL=string.shared.util.js.map

@@ -6,3 +6,5 @@ /**

* There is more advanced version of memo decorator called `memoCache`.
*
* Supports dropping it's cache by calling .dropCache() method of decorated function (useful in unit testing).
*/
export declare const memo: () => (target: any, key: string, descriptor: PropertyDescriptor) => PropertyDescriptor;

@@ -6,11 +6,4 @@ "use strict";

// http://inlehmansterms.net/2015/03/01/javascript-memoization/
/* tslint:disable:no-invalid-this */
Object.defineProperty(exports, "__esModule", { value: true });
var jsonCacheKey = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return JSON.stringify(args);
};
const jsonCacheKey = (...args) => JSON.stringify(args);
/**

@@ -21,26 +14,35 @@ * Memoizes the method of the class, so it caches the output and returns the cached version if the "key"

* There is more advanced version of memo decorator called `memoCache`.
*
* Supports dropping it's cache by calling .dropCache() method of decorated function (useful in unit testing).
*/
exports.memo = function () { return function (target, key, descriptor) {
exports.memo = () => (target, key, descriptor) => {
if (typeof descriptor.value !== 'function') {
throw new Error('Memoization can be applied only to methods');
}
var originalFn = descriptor.value;
var cache = new Map();
descriptor.value = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var cacheKey = jsonCacheKey(args);
const originalFn = descriptor.value;
const cache = new Map();
let loggingEnabled = false;
descriptor.value = function (...args) {
const cacheKey = jsonCacheKey(args);
if (cache.has(cacheKey)) {
var cached = cache.get(cacheKey);
// console.log('returning value from cache: ', cacheKey, key)
const cached = cache.get(cacheKey);
if (loggingEnabled) {
console.log(`memo (method=${key}) returning value from cache: `, cacheKey, key);
}
return cached;
}
var res = originalFn.apply(this, args);
const res = originalFn.apply(this, args);
cache.set(cacheKey, res);
return res;
};
descriptor.value.dropCache = () => {
console.log(`memo.dropCache (method=${key})`);
cache.clear();
};
descriptor.value.setLogging = (enabled = true) => {
loggingEnabled = enabled;
console.log(`memo.loggingEnabled=${enabled} (method=${key})`);
};
return descriptor;
}; };
};
//# sourceMappingURL=memo.decorator.js.map

@@ -11,43 +11,40 @@ "use strict";

/* tslint:disable:no-invalid-this */
var lru_cache_1 = __importDefault(require("lru-cache"));
var jsonCacheKey = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
const lru_cache_1 = __importDefault(require("lru-cache"));
const jsonCacheKey = (...args) => JSON.stringify(args);
exports.memoCache = (opts = {}) => (target, key, descriptor) => {
if (typeof descriptor.value !== 'function') {
throw new Error('Memoization can be applied only to methods');
}
return JSON.stringify(args);
};
exports.memoCache = function (opts) {
if (opts === void 0) { opts = {}; }
return function (target, key, descriptor) {
if (typeof descriptor.value !== 'function') {
throw new Error('Memoization can be applied only to methods');
const originalFn = descriptor.value;
if (!opts.cacheKeyFn)
opts.cacheKeyFn = jsonCacheKey;
const lruOpts = {
max: opts.maxSize || 100,
maxAge: opts.ttl || Infinity,
};
const cache = new lru_cache_1.default(lruOpts);
let loggingEnabled = false;
descriptor.value = function (...args) {
const cacheKey = opts.cacheKeyFn(args);
if (cache.has(cacheKey)) {
const cached = cache.get(cacheKey);
if (loggingEnabled) {
console.log(`memo (method=${key}) returning value from cache: `, cacheKey, key);
}
return cached;
}
var originalFn = descriptor.value;
if (!opts.cacheKeyFn)
opts.cacheKeyFn = jsonCacheKey;
var lruOpts = {
max: opts.maxSize || 100,
maxAge: opts.ttl || Infinity,
};
var cache = new lru_cache_1.default(lruOpts);
// descriptor.value = memoize(descriptor.value, opts.resolver)
descriptor.value = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var cacheKey = opts.cacheKeyFn(args);
if (cache.has(cacheKey)) {
var cached = cache.get(cacheKey);
// console.log('returning value from cache: ', cacheKey, key)
return cached;
}
var res = originalFn.apply(this, args);
cache.set(cacheKey, res);
return res;
};
return descriptor;
const res = originalFn.apply(this, args);
cache.set(cacheKey, res);
return res;
};
descriptor.value.dropCache = () => {
console.log(`memo.dropCache (method=${key})`);
cache.reset();
};
descriptor.value.setLogging = (enabled = true) => {
loggingEnabled = enabled;
console.log(`memo.loggingEnabled=${enabled} (method=${key})`);
};
return descriptor;
};
//# sourceMappingURL=memoCache.decorator.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });

@@ -19,23 +6,20 @@ /**

*/
var AppError = /** @class */ (function (_super) {
__extends(AppError, _super);
function AppError(message, data) {
var _this = _super.call(this, message) || this;
_this.data = data;
Object.defineProperty(_this, 'name', {
value: _this.constructor.name,
class AppError extends Error {
constructor(message, data) {
super(message);
this.data = data;
Object.defineProperty(this, 'name', {
value: this.constructor.name,
});
if (Error.captureStackTrace) {
Error.captureStackTrace(_this, _this.constructor);
Error.captureStackTrace(this, this.constructor);
}
else {
Object.defineProperty(_this, 'stack', {
Object.defineProperty(this, 'stack', {
value: new Error().stack,
});
}
return _this;
}
return AppError;
}(Error));
}
exports.AppError = AppError;
//# sourceMappingURL=app.error.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var memo_decorator_1 = require("./decorators/memo.decorator");
const memo_decorator_1 = require("./decorators/memo.decorator");
exports.memo = memo_decorator_1.memo;
var memoCache_decorator_1 = require("./decorators/memoCache.decorator");
const memoCache_decorator_1 = require("./decorators/memoCache.decorator");
exports.memoCache = memoCache_decorator_1.memoCache;
var app_error_1 = require("./error/app.error");
const app_error_1 = require("./error/app.error");
exports.AppError = app_error_1.AppError;
var test_shared_util_1 = require("./testing/test.shared.util");
const test_shared_util_1 = require("./testing/test.shared.util");
exports.deepFreeze = test_shared_util_1.deepFreeze;

@@ -14,10 +14,10 @@ exports.runAllTests = test_shared_util_1.runAllTests;

exports.silentConsoleIfRunAll = test_shared_util_1.silentConsoleIfRunAll;
var object_util_1 = require("./util/object.util");
const object_util_1 = require("./util/object.util");
exports.objectUtil = object_util_1.objectUtil;
var random_shared_util_1 = require("./util/random.shared.util");
const random_shared_util_1 = require("./util/random.shared.util");
exports.randomSharedUtil = random_shared_util_1.randomSharedUtil;
var script_shared_util_1 = require("./util/script.shared.util");
const script_shared_util_1 = require("./util/script.shared.util");
exports.scriptSharedUtil = script_shared_util_1.scriptSharedUtil;
var string_shared_util_1 = require("./util/string.shared.util");
const string_shared_util_1 = require("./util/string.shared.util");
exports.stringSharedUtil = string_shared_util_1.stringSharedUtil;
//# sourceMappingURL=index.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.freeze(o);
Object.getOwnPropertyNames(o).forEach(function (prop) {
Object.getOwnPropertyNames(o).forEach(prop => {
if (o.hasOwnProperty(prop) &&

@@ -19,14 +19,14 @@ o[prop] !== null &&

function silentConsole() {
console.log = function () { return undefined; };
console.debug = function () { return undefined; };
console.info = function () { return undefined; };
console.warn = function () { return undefined; };
console.error = function () { return undefined; };
console.time = function () { return undefined; };
console.table = function () { return undefined; };
console.log = () => undefined;
console.debug = () => undefined;
console.info = () => undefined;
console.warn = () => undefined;
console.error = () => undefined;
console.time = () => undefined;
console.table = () => undefined;
}
exports.silentConsole = silentConsole;
function runAllTests() {
var args = process.argv.slice();
var lastArg = args.filter(function (x) { return !x.startsWith('-'); }).pop();
const args = process.argv.slice();
const lastArg = args.filter(x => !x.startsWith('-')).pop();
return ((lastArg && (lastArg.endsWith('/jest') || lastArg.endsWith('/jest-worker/build/child.js'))) ||

@@ -33,0 +33,0 @@ false);

"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var ObjectUtil = /** @class */ (function () {
function ObjectUtil() {
}
class ObjectUtil {
// Picks just allowed fields and no other fields
// pick<T> (obj: any, fields: string[], initialObject = {}): T {
ObjectUtil.prototype.pick = function (obj, fields, initialObject) {
if (initialObject === void 0) { initialObject = {}; }
pick(obj, fields, initialObject = {}) {
if (!obj || !fields || !fields.length)
return obj;
var o = initialObject;
fields.forEach(function (k) {
const o = initialObject;
fields.forEach(k => {
if (k in obj)

@@ -29,3 +15,3 @@ o[k] = obj[k];

return o;
};
}
/**

@@ -35,21 +21,17 @@ * Does NOT mutate (unless "mutate" flag is set)

*/
ObjectUtil.prototype.filterFalsyValues = function (_obj, mutate) {
if (mutate === void 0) { mutate = false; }
return this.filterValues(_obj, function (k, v) { return !!v; }, mutate);
};
ObjectUtil.prototype.filterEmptyStringValues = function (_obj, mutate) {
if (mutate === void 0) { mutate = false; }
return this.filterValues(_obj, function (k, v) { return v !== ''; }, mutate);
};
ObjectUtil.prototype.filterUndefinedValues = function (_obj, mutate) {
if (mutate === void 0) { mutate = false; }
return this.filterValues(_obj, function (k, v) { return v !== undefined && v !== null; }, mutate);
};
ObjectUtil.prototype.filterValues = function (_obj, predicate, mutate) {
if (mutate === void 0) { mutate = false; }
filterFalsyValues(_obj, mutate = false) {
return this.filterValues(_obj, (k, v) => !!v, mutate);
}
filterEmptyStringValues(_obj, mutate = false) {
return this.filterValues(_obj, (k, v) => v !== '', mutate);
}
filterUndefinedValues(_obj, mutate = false) {
return this.filterValues(_obj, (k, v) => v !== undefined && v !== null, mutate);
}
filterValues(_obj, predicate, mutate = false) {
if (!this.isObject(_obj))
return _obj;
var o = mutate ? _obj : __assign({}, _obj);
Object.keys(o).forEach(function (k) {
var keep = predicate(k, o[k]);
const o = mutate ? _obj : Object.assign({}, _obj);
Object.keys(o).forEach(k => {
const keep = predicate(k, o[k]);
if (!keep)

@@ -59,16 +41,14 @@ delete o[k];

return o;
};
ObjectUtil.prototype.transformValues = function (_obj, transformFn, mutate) {
if (mutate === void 0) { mutate = false; }
}
transformValues(_obj, transformFn, mutate = false) {
if (!this.isObject(_obj))
return _obj;
var o = mutate ? _obj : __assign({}, _obj);
Object.keys(o).forEach(function (k) {
const o = mutate ? _obj : Object.assign({}, _obj);
Object.keys(o).forEach(k => {
o[k] = transformFn(k, o[k]);
});
return o;
};
ObjectUtil.prototype.objectNullValuesToUndefined = function (_obj, mutate) {
if (mutate === void 0) { mutate = false; }
return this.transformValues(_obj, function (k, v) {
}
objectNullValuesToUndefined(_obj, mutate = false) {
return this.transformValues(_obj, (k, v) => {
if (v === null)

@@ -78,31 +58,29 @@ return undefined;

}, mutate);
};
ObjectUtil.prototype.deepEquals = function (a, b) {
}
deepEquals(a, b) {
return JSON.stringify(this.sortObjectDeep(a)) === JSON.stringify(this.sortObjectDeep(b));
};
}
/**
* Deep copy object (by json parse/stringify).
*/
ObjectUtil.prototype.deepCopy = function (o) {
deepCopy(o) {
return JSON.parse(JSON.stringify(o));
};
ObjectUtil.prototype.isObject = function (item) {
}
isObject(item) {
return (item && typeof item === 'object' && !Array.isArray(item) && item !== null) || false;
};
ObjectUtil.prototype.isEmptyObject = function (obj) {
}
isEmptyObject(obj) {
return obj && obj.constructor === Object && Object.keys(obj).length === 0;
};
}
// from: https://gist.github.com/Salakar/1d7137de9cb8b704e48a
ObjectUtil.prototype.mergeDeep = function (target, source) {
var _this = this;
mergeDeep(target, source) {
if (this.isObject(target) && this.isObject(source)) {
Object.keys(source).forEach(function (key) {
var _a, _b;
if (_this.isObject(source[key])) {
Object.keys(source).forEach(key => {
if (this.isObject(source[key])) {
if (!target[key])
Object.assign(target, (_a = {}, _a[key] = {}, _a));
_this.mergeDeep(target[key], source[key]);
Object.assign(target, { [key]: {} });
this.mergeDeep(target[key], source[key]);
}
else {
Object.assign(target, (_b = {}, _b[key] = source[key], _b));
Object.assign(target, { [key]: source[key] });
}

@@ -112,8 +90,7 @@ });

return target;
};
}
/**
* Mutates
*/
ObjectUtil.prototype.deepTrim = function (o) {
var _this = this;
deepTrim(o) {
if (!o)

@@ -125,32 +102,31 @@ return o;

else if (typeof o === 'object') {
Object.keys(o).forEach(function (k) {
o[k] = _this.deepTrim(o[k]);
Object.keys(o).forEach(k => {
o[k] = this.deepTrim(o[k]);
});
}
return o;
};
ObjectUtil.prototype.defaultSortFn = function (a, b) {
}
defaultSortFn(a, b) {
return a.localeCompare(b);
};
}
// based on: https://github.com/IndigoUnited/js-deep-sort-object
ObjectUtil.prototype.sortObjectDeep = function (o) {
var _this = this;
sortObjectDeep(o) {
// array
if (Array.isArray(o)) {
return o.map(function (i) { return _this.sortObjectDeep(i); });
return o.map(i => this.sortObjectDeep(i));
}
if (this.isObject(o)) {
var out_1 = {};
const out = {};
Object.keys(o)
.sort(function (a, b) { return _this.defaultSortFn(a, b); })
.forEach(function (k) {
out_1[k] = _this.sortObjectDeep(o[k]);
.sort((a, b) => this.defaultSortFn(a, b))
.forEach(k => {
out[k] = this.sortObjectDeep(o[k]);
});
return out_1;
return out;
}
return o;
};
}
// from: https://github.com/jonschlinkert/unset-value
// mutates obj
ObjectUtil.prototype.unsetValue = function (obj, prop) {
unsetValue(obj, prop) {
if (!this.isObject(obj)) {

@@ -163,4 +139,4 @@ return;

}
var segs = prop.split('.');
var last = segs.pop();
const segs = prop.split('.');
let last = segs.pop();
while (segs.length && segs[segs.length - 1].slice(-1) === '\\') {

@@ -170,3 +146,3 @@ last = segs.pop().slice(0, -1) + '.' + last;

while (segs.length && this.isObject(obj)) {
var k = (prop = segs.shift());
const k = (prop = segs.shift());
obj = obj[k];

@@ -177,3 +153,3 @@ }

delete obj[last];
};
}
/**

@@ -189,49 +165,44 @@ * Returns object with filtered keys from "exclude" array.

*/
ObjectUtil.prototype.mask = function (_o, exclude, deepCopy) {
var _this = this;
if (deepCopy === void 0) { deepCopy = false; }
var o = __assign({}, _o);
mask(_o, exclude, deepCopy = false) {
let o = Object.assign({}, _o);
if (deepCopy)
o = this.deepCopy(o);
exclude.forEach(function (e) {
exclude.forEach(e => {
// eval(`delete o.${e}`)
_this.unsetValue(o, e);
this.unsetValue(o, e);
});
return o;
};
}
/**
* Turns ['a', b'] into {a: true, b: true}
*/
ObjectUtil.prototype.arrayToHash = function (a) {
if (a === void 0) { a = []; }
return a.reduce(function (o, item) {
arrayToHash(a = []) {
return a.reduce((o, item) => {
o[item] = true;
return o;
}, {});
};
ObjectUtil.prototype.classToPlain = function (obj) {
if (obj === void 0) { obj = {}; }
}
classToPlain(obj = {}) {
return JSON.parse(JSON.stringify(obj));
};
ObjectUtil.prototype.getKeyByValue = function (object, value) {
}
getKeyByValue(object, value) {
if (!this.isObject(object))
return;
return Object.keys(object).find(function (k) { return object[k] === value; });
};
ObjectUtil.prototype.invertObject = function (o) {
var inv = {};
Object.keys(o).forEach(function (k) {
return Object.keys(object).find(k => object[k] === value);
}
invertObject(o) {
const inv = {};
Object.keys(o).forEach(k => {
inv[o[k]] = k;
});
return inv;
};
ObjectUtil.prototype.invertMap = function (m) {
var inv = new Map();
m.forEach(function (v, k) { return inv.set(v, k); });
}
invertMap(m) {
const inv = new Map();
m.forEach((v, k) => inv.set(v, k));
return inv;
};
ObjectUtil.prototype.by = function (items, by) {
if (items === void 0) { items = []; }
var r = {};
items.forEach(function (item) {
}
by(items = [], by) {
const r = {};
items.forEach((item) => {
if (item[by])

@@ -241,7 +212,6 @@ r[item[by]] = item;

return r;
};
return ObjectUtil;
}());
}
}
exports.ObjectUtil = ObjectUtil;
exports.objectUtil = new ObjectUtil();
//# sourceMappingURL=object.util.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var RandomSharedUtil = /** @class */ (function () {
function RandomSharedUtil() {
class RandomSharedUtil {
randomInt(minIncl, maxIncl) {
return Math.floor(Math.random() * (maxIncl - minIncl + 1) + minIncl);
}
RandomSharedUtil.prototype.randomInt = function (minIncl, maxIncl) {
return Math.floor(Math.random() * (maxIncl - minIncl + 1) + minIncl);
};
return RandomSharedUtil;
}());
}
exports.randomSharedUtil = new RandomSharedUtil();
//# sourceMappingURL=random.shared.util.js.map

@@ -10,52 +10,19 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var ScriptSharedUtil = /** @class */ (function () {
function ScriptSharedUtil() {
}
ScriptSharedUtil.prototype.loadScript = function (src, async) {
if (async === void 0) { async = true; }
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve, reject) {
var s = document.createElement('script');
s.src = src;
s.onload = resolve;
s.onerror = reject;
if (async)
s.async = true;
document.head.appendChild(s);
})];
class ScriptSharedUtil {
loadScript(src, async = true) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
const s = document.createElement('script');
s.src = src;
s.onload = resolve;
s.onerror = reject;
if (async)
s.async = true;
document.head.appendChild(s);
});
});
};
return ScriptSharedUtil;
}());
}
}
exports.scriptSharedUtil = new ScriptSharedUtil();
//# sourceMappingURL=script.shared.util.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var StringSharedUtil = /** @class */ (function () {
function StringSharedUtil() {
class StringSharedUtil {
capitalizeFirstLetter(s) {
return s.charAt(0).toUpperCase() + s.slice(1);
}
StringSharedUtil.prototype.capitalizeFirstLetter = function (s) {
return s.charAt(0).toUpperCase() + s.slice(1);
};
StringSharedUtil.prototype.lowercaseFirstLetter = function (s) {
lowercaseFirstLetter(s) {
return s.charAt(0).toLowerCase() + s.slice(1);
};
StringSharedUtil.prototype.removeWhitespace = function (s) {
}
removeWhitespace(s) {
return s.replace(/\s/g, '');
};
return StringSharedUtil;
}());
}
}
exports.StringSharedUtil = StringSharedUtil;
exports.stringSharedUtil = new StringSharedUtil();
//# sourceMappingURL=string.shared.util.js.map

@@ -14,3 +14,3 @@ {

"peerDependencies": {
"lru-cache": ">=4.0.0"
"lru-cache": ">=5.0.0"
},

@@ -25,3 +25,3 @@ "devDependencies": {

"jest-junit": "^5.2.0",
"lru-cache": "^4.1.3",
"lru-cache": "^5.1.1",
"luxon": "^1.4.3",

@@ -33,3 +33,3 @@ "prettier": "^1.14.3",

"tslint": "^5.11.0",
"typescript": "^3.0.0"
"typescript": "^3.2.2"
},

@@ -51,3 +51,3 @@ "files": [

},
"version": "1.0.77",
"version": "1.0.79",
"description": "",

@@ -54,0 +54,0 @@ "author": "Natural Cycles Team",

@@ -5,2 +5,3 @@ // Based on:

// http://inlehmansterms.net/2015/03/01/javascript-memoization/
/* tslint:disable:no-invalid-this */

@@ -17,2 +18,4 @@

* There is more advanced version of memo decorator called `memoCache`.
*
* Supports dropping it's cache by calling .dropCache() method of decorated function (useful in unit testing).
*/

@@ -31,2 +34,3 @@ export const memo = () => (

const cache = new Map<string, any>()
let loggingEnabled = false

@@ -38,3 +42,5 @@ descriptor.value = function (...args: any[]): any {

const cached = cache.get(cacheKey)
// console.log('returning value from cache: ', cacheKey, key)
if (loggingEnabled) {
console.log(`memo (method=${key}) returning value from cache: `, cacheKey, key)
}
return cached

@@ -48,3 +54,13 @@ }

descriptor.value.dropCache = () => {
console.log(`memo.dropCache (method=${key})`)
cache.clear()
}
descriptor.value.setLogging = (enabled = true) => {
loggingEnabled = enabled
console.log(`memo.loggingEnabled=${enabled} (method=${key})`)
}
return descriptor
}

@@ -36,4 +36,4 @@ // Based on:

const cache = new LRU<string, any>(lruOpts)
let loggingEnabled = false
// descriptor.value = memoize(descriptor.value, opts.resolver)
descriptor.value = function (...args: any[]): any {

@@ -44,3 +44,5 @@ const cacheKey = opts.cacheKeyFn!(args)

const cached = cache.get(cacheKey)
// console.log('returning value from cache: ', cacheKey, key)
if (loggingEnabled) {
console.log(`memo (method=${key}) returning value from cache: `, cacheKey, key)
}
return cached

@@ -54,3 +56,13 @@ }

descriptor.value.dropCache = () => {
console.log(`memo.dropCache (method=${key})`)
cache.reset()
}
descriptor.value.setLogging = (enabled = true) => {
loggingEnabled = enabled
console.log(`memo.loggingEnabled=${enabled} (method=${key})`)
}
return descriptor
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc