import { assertNodeEngineVersion } from 'appcd-util';// throw an exception if current node version doesn't satisfy the `engines.node` versionassertNodeEngineVersion(require('package.json'));
import { cache } from 'appcd-util';const now = () => Date.now();const first = await cache('my namespace', now);const second = await cache('my namespace', now);assert(first === second);const third = await cache('my namespace', true, now);assert(first !== third && second !== third);
import { cacheSync } from 'appcd-util';const now = () => Date.now();const first = cacheSync('my namespace', now);const second = cacheSync('my namespace', now);assert(first === second);const third = cacheSync('my namespace', true, now);assert(first !== third && second !== third);
Debouncer that returns a promise and that can be cancelled.
import { debounce } from 'appcd-util';const fn = debounce(() => { console.log(new Date());});// schedule the callback to be called in 200msfn().then(() => { console.log('Function called');});// cancel the debouncefn.cancel();
import { get } from 'appcd-util';const obj = { foo: 'bar'};console.log(get(obj, 'foo')); // 'bar'console.log(get(obj, 'baz', 'pow')); // 'pow'
Get all open sockets, [net] servers, timers, child processes, filesystem watchers, and other
handles.
import { getActiveHandles } from 'appcd-util';console.log(getActiveHandles());
import { inherits } from 'appcd-util';class A {}class B extends A {}class C {}console.log(inherits(B, A)); // trueconsole.log(inherits(B, C)); // false
This project is open source under the Apache Public License v2 and is developed by
Axway, Inc and the community. Please read the LICENSE file included
in this distribution for more information.