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

@thi.ng/api

Package Overview
Dependencies
Maintainers
1
Versions
188
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/api - npm Package Compare versions

Comparing version 6.3.1 to 6.3.2

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

## [6.3.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@6.3.1...@thi.ng/api@6.3.2) (2019-07-31)
**Note:** Version bump only for package @thi.ng/api
## [6.3.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@6.3.0...@thi.ng/api@6.3.1) (2019-07-12)

@@ -8,0 +16,0 @@

284

lib/index.umd.js

@@ -1,283 +0,1 @@

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@thi.ng/errors')) :
typeof define === 'function' && define.amd ? define(['exports', '@thi.ng/errors'], factory) :
(global = global || self, factory((global.thi = global.thi || {}, global.thi.ng = global.thi.ng || {}, global.thi.ng.api = {}), global.thi.ng.errors));
}(this, function (exports, errors) { 'use strict';
const DEFAULT_EPS = 1e-6;
const EVENT_ALL = "*";
const EVENT_ENABLE = "enable";
const EVENT_DISABLE = "disable";
const SEMAPHORE = Symbol();
const NO_OP = () => { };
(function (Type) {
Type[Type["U8"] = 0] = "U8";
Type[Type["U8C"] = 1] = "U8C";
Type[Type["I8"] = 2] = "I8";
Type[Type["U16"] = 3] = "U16";
Type[Type["I16"] = 4] = "I16";
Type[Type["U32"] = 5] = "U32";
Type[Type["I32"] = 6] = "I32";
Type[Type["F32"] = 7] = "F32";
Type[Type["F64"] = 8] = "F64";
})(exports.Type || (exports.Type = {}));
const SIZEOF = {
[0 ]: 1,
[1 ]: 1,
[2 ]: 1,
[3 ]: 2,
[4 ]: 2,
[5 ]: 4,
[6 ]: 4,
[7 ]: 4,
[8 ]: 8
};
(function (LogLevel) {
LogLevel[LogLevel["FINE"] = 0] = "FINE";
LogLevel[LogLevel["DEBUG"] = 1] = "DEBUG";
LogLevel[LogLevel["INFO"] = 2] = "INFO";
LogLevel[LogLevel["WARN"] = 3] = "WARN";
LogLevel[LogLevel["SEVERE"] = 4] = "SEVERE";
LogLevel[LogLevel["NONE"] = 5] = "NONE";
})(exports.LogLevel || (exports.LogLevel = {}));
const assert = typeof process === "undefined" ||
process.env.NODE_ENV !== "production" ||
process.env.UMBRELLA_ASSERTS === "1"
? (test, msg = "assertion failed") => {
if ((typeof test === "function" && !test()) || !test) {
throw new Error(typeof msg === "function" ? msg() : msg);
}
}
: NO_OP;
const NULL_LOGGER = Object.freeze({
level: exports.LogLevel.NONE,
fine() { },
debug() { },
info() { },
warn() { },
severe() { }
});
class ConsoleLogger {
constructor(id, level = exports.LogLevel.FINE) {
this.id = id;
this.level = level;
}
fine(...args) {
this.level <= exports.LogLevel.FINE && this.log("FINE", args);
}
debug(...args) {
this.level <= exports.LogLevel.DEBUG && this.log("DEBUG", args);
}
info(...args) {
this.level <= exports.LogLevel.INFO && this.log("INFO", args);
}
warn(...args) {
this.level <= exports.LogLevel.WARN && this.log("WARN", args);
}
severe(...args) {
this.level <= exports.LogLevel.SEVERE && this.log("SEVERE", args);
}
log(level, args) {
console.log(`[${level}] ${this.id}:`, ...args);
}
}
const mixin = (behaviour, sharedBehaviour = {}) => {
const instanceKeys = Reflect.ownKeys(behaviour);
const sharedKeys = Reflect.ownKeys(sharedBehaviour);
const typeTag = Symbol("isa");
function _mixin(clazz) {
for (let key of instanceKeys) {
const existing = Object.getOwnPropertyDescriptor(clazz.prototype, key);
if (!existing || existing.configurable) {
Object.defineProperty(clazz.prototype, key, {
value: behaviour[key],
writable: true
});
}
else {
console.log(`not patching: ${clazz.name}.${key.toString()}`);
}
}
Object.defineProperty(clazz.prototype, typeTag, { value: true });
return clazz;
}
for (let key of sharedKeys) {
Object.defineProperty(_mixin, key, {
value: sharedBehaviour[key],
enumerable: sharedBehaviour.propertyIsEnumerable(key)
});
}
Object.defineProperty(_mixin, Symbol.hasInstance, {
value: (x) => !!x[typeTag]
});
return _mixin;
};
const configurable = (state) => function (_, __, descriptor) {
descriptor.configurable = state;
};
const deprecated = (msg, log = console.log) => function (target, prop, descriptor) {
const signature = `${target.constructor.name}#${prop.toString()}`;
const fn = descriptor.value;
if (typeof fn !== "function") {
errors.illegalArgs(`${signature} is not a function`);
}
descriptor.value = function () {
log(`DEPRECATED ${signature}: ${msg || "will be removed soon"}`);
return fn.apply(this, arguments);
};
return descriptor;
};
const nomixin = (_, __, descriptor) => {
descriptor.configurable = false;
};
const sealed = (constructor) => {
Object.seal(constructor);
Object.seal(constructor.prototype);
};
const IEnableMixin = mixin({
_enabled: true,
isEnabled() {
return this._enabled;
},
enable() {
const $this = this;
$this._enabled = true;
if ($this.notify) {
$this.notify({ id: EVENT_ENABLE, target: this });
}
},
disable() {
const $this = this;
$this._enabled = false;
if ($this.notify) {
$this.notify({ id: EVENT_DISABLE, target: this });
}
},
toggle() {
this._enabled ? this.disable() : this.enable();
return this._enabled;
}
});
const inotify_dispatch = (listeners, e) => {
if (!listeners)
return;
for (let i = 0, n = listeners.length, l; i < n; i++) {
l = listeners[i];
l[0].call(l[1], e);
if (e.canceled) {
return;
}
}
};
const INotifyMixin = mixin({
addListener(id, fn, scope) {
let l = (this._listeners =
this._listeners || {})[id];
if (!l) {
l = this._listeners[id] = [];
}
if (this.__listener(l, fn, scope) === -1) {
l.push([fn, scope]);
return true;
}
return false;
},
removeListener(id, fn, scope) {
if (!this._listeners)
return false;
const l = this._listeners[id];
if (l) {
const idx = this.__listener(l, fn, scope);
if (idx !== -1) {
l.splice(idx, 1);
return true;
}
}
return false;
},
notify(e) {
if (!this._listeners)
return;
e.target === undefined && (e.target = this);
inotify_dispatch(this._listeners[e.id], e);
inotify_dispatch(this._listeners[EVENT_ALL], e);
},
__listener(listeners, f, scope) {
let i = listeners.length;
while (--i >= 0) {
const l = listeners[i];
if (l[0] === f && l[1] === scope) {
break;
}
}
return i;
}
});
const iterable = (prop) => mixin({
*[Symbol.iterator]() {
yield* this[prop];
}
});
const IWatchMixin = mixin({
addWatch(id, fn) {
this._watches = this._watches || {};
if (this._watches[id]) {
return false;
}
this._watches[id] = fn;
return true;
},
removeWatch(id) {
if (!this._watches)
return;
if (this._watches[id]) {
delete this._watches[id];
return true;
}
return false;
},
notifyWatches(oldState, newState) {
if (!this._watches)
return;
const w = this._watches;
for (let id in w) {
w[id](id, oldState, newState);
}
}
});
exports.ConsoleLogger = ConsoleLogger;
exports.DEFAULT_EPS = DEFAULT_EPS;
exports.EVENT_ALL = EVENT_ALL;
exports.EVENT_DISABLE = EVENT_DISABLE;
exports.EVENT_ENABLE = EVENT_ENABLE;
exports.IEnableMixin = IEnableMixin;
exports.INotifyMixin = INotifyMixin;
exports.IWatchMixin = IWatchMixin;
exports.NO_OP = NO_OP;
exports.NULL_LOGGER = NULL_LOGGER;
exports.SEMAPHORE = SEMAPHORE;
exports.SIZEOF = SIZEOF;
exports.assert = assert;
exports.configurable = configurable;
exports.deprecated = deprecated;
exports.inotify_dispatch = inotify_dispatch;
exports.iterable = iterable;
exports.mixin = mixin;
exports.nomixin = nomixin;
exports.sealed = sealed;
Object.defineProperty(exports, '__esModule', { value: true });
}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@thi.ng/errors")):"function"==typeof define&&define.amd?define(["exports","@thi.ng/errors"],t):t(((e=e||self).thi=e.thi||{},e.thi.ng=e.thi.ng||{},e.thi.ng.api={}),e.thi.ng.errors)}(this,function(e,t){"use strict";const i=Symbol(),n=()=>{};var s;(s=e.Type||(e.Type={}))[s.U8=0]="U8",s[s.U8C=1]="U8C",s[s.I8=2]="I8",s[s.U16=3]="U16",s[s.I16=4]="I16",s[s.U32=5]="U32",s[s.I32=6]="I32",s[s.F32=7]="F32",s[s.F64=8]="F64";const o={0:1,1:1,2:1,3:2,4:2,5:4,6:4,7:4,8:8};var r;(r=e.LogLevel||(e.LogLevel={}))[r.FINE=0]="FINE",r[r.DEBUG=1]="DEBUG",r[r.INFO=2]="INFO",r[r.WARN=3]="WARN",r[r.SEVERE=4]="SEVERE",r[r.NONE=5]="NONE";const l="undefined"==typeof process||"production"!==process.env.NODE_ENV||"1"===process.env.UMBRELLA_ASSERTS?(e,t="assertion failed")=>{if("function"==typeof e&&!e()||!e)throw new Error("function"==typeof t?t():t)}:n,a=Object.freeze({level:e.LogLevel.NONE,fine(){},debug(){},info(){},warn(){},severe(){}});const c=(e,t={})=>{const i=Reflect.ownKeys(e),n=Reflect.ownKeys(t),s=Symbol("isa");function o(t){for(let n of i){const i=Object.getOwnPropertyDescriptor(t.prototype,n);!i||i.configurable?Object.defineProperty(t.prototype,n,{value:e[n],writable:!0}):console.log(`not patching: ${t.name}.${n.toString()}`)}return Object.defineProperty(t.prototype,s,{value:!0}),t}for(let e of n)Object.defineProperty(o,e,{value:t[e],enumerable:t.propertyIsEnumerable(e)});return Object.defineProperty(o,Symbol.hasInstance,{value:e=>!!e[s]}),o},h=c({_enabled:!0,isEnabled(){return this._enabled},enable(){const e=this;e._enabled=!0,e.notify&&e.notify({id:"enable",target:this})},disable(){const e=this;e._enabled=!1,e.notify&&e.notify({id:"disable",target:this})},toggle(){return this._enabled?this.disable():this.enable(),this._enabled}}),f=(e,t)=>{if(e)for(let i,n=0,s=e.length;n<s;n++)if((i=e[n])[0].call(i[1],t),t.canceled)return},u=c({addListener(e,t,i){let n=(this._listeners=this._listeners||{})[e];return n||(n=this._listeners[e]=[]),-1===this.__listener(n,t,i)&&(n.push([t,i]),!0)},removeListener(e,t,i){if(!this._listeners)return!1;const n=this._listeners[e];if(n){const e=this.__listener(n,t,i);if(-1!==e)return n.splice(e,1),!0}return!1},notify(e){this._listeners&&(void 0===e.target&&(e.target=this),f(this._listeners[e.id],e),f(this._listeners["*"],e))},__listener(e,t,i){let n=e.length;for(;--n>=0;){const s=e[n];if(s[0]===t&&s[1]===i)break}return n}}),E=c({addWatch(e,t){return this._watches=this._watches||{},!this._watches[e]&&(this._watches[e]=t,!0)},removeWatch(e){if(this._watches)return!!this._watches[e]&&(delete this._watches[e],!0)},notifyWatches(e,t){if(!this._watches)return;const i=this._watches;for(let n in i)i[n](n,e,t)}});e.ConsoleLogger=class{constructor(t,i=e.LogLevel.FINE){this.id=t,this.level=i}fine(...t){this.level<=e.LogLevel.FINE&&this.log("FINE",t)}debug(...t){this.level<=e.LogLevel.DEBUG&&this.log("DEBUG",t)}info(...t){this.level<=e.LogLevel.INFO&&this.log("INFO",t)}warn(...t){this.level<=e.LogLevel.WARN&&this.log("WARN",t)}severe(...t){this.level<=e.LogLevel.SEVERE&&this.log("SEVERE",t)}log(e,t){console.log(`[${e}] ${this.id}:`,...t)}},e.DEFAULT_EPS=1e-6,e.EVENT_ALL="*",e.EVENT_DISABLE="disable",e.EVENT_ENABLE="enable",e.IEnableMixin=h,e.INotifyMixin=u,e.IWatchMixin=E,e.NO_OP=n,e.NULL_LOGGER=a,e.SEMAPHORE=i,e.SIZEOF=o,e.assert=l,e.configurable=e=>(function(t,i,n){n.configurable=e}),e.deprecated=(e,i=console.log)=>(function(n,s,o){const r=`${n.constructor.name}#${s.toString()}`,l=o.value;return"function"!=typeof l&&t.illegalArgs(`${r} is not a function`),o.value=function(){return i(`DEPRECATED ${r}: ${e||"will be removed soon"}`),l.apply(this,arguments)},o}),e.inotify_dispatch=f,e.iterable=e=>c({*[Symbol.iterator](){yield*this[e]}}),e.mixin=c,e.nomixin=(e,t,i)=>{i.configurable=!1},e.sealed=e=>{Object.seal(e),Object.seal(e.prototype)},Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "@thi.ng/api",
"version": "6.3.1",
"version": "6.3.2",
"description": "Common, generic types & interfaces for thi.ng projects",

@@ -17,21 +17,22 @@ "module": "./index.js",

"scripts": {
"build": "yarn clean && yarn build:es6 && yarn build:bundle",
"build": "yarn clean && yarn build:es6 && node ../../scripts/bundle-module",
"build:release": "yarn clean && yarn build:es6 && node ../../scripts/bundle-module all",
"build:es6": "tsc --declaration",
"build:bundle": "../../scripts/bundle-module",
"test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js",
"build:test": "rimraf build && tsc -p test/tsconfig.json",
"test": "yarn build:test && mocha build/test/*.js",
"cover": "yarn build:test && nyc mocha build/test/*.js && nyc report --reporter=lcov",
"clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib decorators mixins",
"cover": "yarn test && nyc report --reporter=lcov",
"doc": "node_modules/.bin/typedoc --mode modules --out doc --ignoreCompilerErrors src",
"pub": "yarn build && yarn publish --access public"
"pub": "yarn build:release && yarn publish --access public"
},
"devDependencies": {
"@types/mocha": "^5.2.6",
"@types/node": "^12.0.8",
"@types/node": "^12.6.3",
"mocha": "^6.1.4",
"nyc": "^14.0.0",
"typedoc": "^0.14.2",
"typescript": "^3.5.2"
"typescript": "^3.5.3"
},
"dependencies": {
"@thi.ng/errors": "^1.1.1"
"@thi.ng/errors": "^1.1.2"
},

@@ -59,3 +60,3 @@ "keywords": [

"sideEffects": false,
"gitHead": "47075afc37f3a16adee7c903a2935304c7cf5daf"
"gitHead": "53eec7988c378fc37ae140e7174f36ef9b6208fe"
}
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