@thi.ng/api
Advanced tools
Comparing version 4.2.4 to 5.0.0
10
api.d.ts
@@ -18,4 +18,12 @@ export declare const DEFAULT_EPS = 0.000001; | ||
*/ | ||
export declare type Fn<A, B> = (x: A) => B; | ||
export declare type Fn<A, B> = (a: A) => B; | ||
/** | ||
* A 2-arg function from A,B => C. | ||
*/ | ||
export declare type Fn2<A, B, C> = (a: A, b: B) => C; | ||
/** | ||
* A 3-arg function from A,B,C => D. | ||
*/ | ||
export declare type Fn3<A, B, C, D> = (a: A, b: B, c: C) => D; | ||
/** | ||
* A vararg arg function to type T. | ||
@@ -22,0 +30,0 @@ */ |
12
api.js
@@ -1,7 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DEFAULT_EPS = 1e-6; | ||
exports.EVENT_ALL = "*"; | ||
exports.EVENT_ENABLE = "enable"; | ||
exports.EVENT_DISABLE = "disable"; | ||
exports.SEMAPHORE = Symbol(); | ||
export const DEFAULT_EPS = 1e-6; | ||
export const EVENT_ALL = "*"; | ||
export const EVENT_ENABLE = "enable"; | ||
export const EVENT_DISABLE = "disable"; | ||
export const SEMAPHORE = Symbol(); |
@@ -6,2 +6,31 @@ # Change Log | ||
# [5.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@4.2.4...@thi.ng/api@5.0.0) (2019-01-21) | ||
### Bug Fixes | ||
* **api:** update assert(), re-export mixin() ([9f91cfa](https://github.com/thi-ng/umbrella/commit/9f91cfa)) | ||
### Build System | ||
* **api:** update package build scripts / outputs ([f913d7b](https://github.com/thi-ng/umbrella/commit/f913d7b)) | ||
### Features | ||
* **api:** add assert() ([d381ace](https://github.com/thi-ng/umbrella/commit/d381ace)) | ||
### BREAKING CHANGES | ||
* **api:** rename mixins to avoid name clashes, update decorators | ||
- append `Mixin` suffix to all mixins (i.e. `INotify` => `INotifyMixin`) | ||
- update re-exports of mixins & decorators (no more nested child namespace) | ||
## [4.2.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@4.2.3...@thi.ng/api@4.2.4) (2018-12-15) | ||
@@ -8,0 +37,0 @@ |
@@ -7,2 +7,2 @@ /** | ||
*/ | ||
export declare function configurable(state: boolean): MethodDecorator; | ||
export declare const configurable: (state: boolean) => MethodDecorator; |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
@@ -9,7 +7,4 @@ * Property decorator factory. Sets `configurable` flag of PropertyDescriptor | ||
*/ | ||
function configurable(state) { | ||
return function (_, __, descriptor) { | ||
descriptor.configurable = state; | ||
}; | ||
} | ||
exports.configurable = configurable; | ||
export const configurable = (state) => function (_, __, descriptor) { | ||
descriptor.configurable = state; | ||
}; |
@@ -9,5 +9,5 @@ /** | ||
*/ | ||
export declare function deprecated(msg?: string, log?: { | ||
export declare const deprecated: (msg?: string, log?: { | ||
(message?: any, ...optionalParams: any[]): void; | ||
(message?: any, ...optionalParams: any[]): void; | ||
}): MethodDecorator; | ||
}) => MethodDecorator; |
@@ -1,4 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const errors_1 = require("@thi.ng/errors"); | ||
import { illegalArgs } from "@thi.ng/errors"; | ||
/** | ||
@@ -12,16 +10,13 @@ * Method property decorator factory. Augments original method with | ||
*/ | ||
function deprecated(msg, log = console.log) { | ||
return function (target, prop, descriptor) { | ||
const signature = `${target.constructor.name}#${prop.toString()}`; | ||
const fn = descriptor.value; | ||
if (typeof fn !== "function") { | ||
errors_1.illegalArgs(`${signature} is not a function`); | ||
} | ||
descriptor.value = function () { | ||
log(`DEPRECATED ${signature}: ${msg || "will be removed soon"}`); | ||
return fn.apply(this, arguments); | ||
}; | ||
return descriptor; | ||
export 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") { | ||
illegalArgs(`${signature} is not a function`); | ||
} | ||
descriptor.value = function () { | ||
log(`DEPRECATED ${signature}: ${msg || "will be removed soon"}`); | ||
return fn.apply(this, arguments); | ||
}; | ||
} | ||
exports.deprecated = deprecated; | ||
return descriptor; | ||
}; |
@@ -8,2 +8,2 @@ /** | ||
*/ | ||
export declare function nomixin(_: any, __: string, descriptor: PropertyDescriptor): void; | ||
export declare const nomixin: (_: any, __: string, descriptor: PropertyDescriptor) => void; |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
@@ -10,5 +8,4 @@ * Method property decorator. Sets `configurable` flag of | ||
*/ | ||
function nomixin(_, __, descriptor) { | ||
export const nomixin = (_, __, descriptor) => { | ||
descriptor.configurable = false; | ||
} | ||
exports.nomixin = nomixin; | ||
}; |
@@ -6,2 +6,2 @@ /** | ||
*/ | ||
export declare function sealed(constructor: Function): void; | ||
export declare const sealed: (constructor: Function) => void; |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
@@ -8,6 +6,5 @@ * Class decorator. Seals both constructor and prototype. | ||
*/ | ||
function sealed(constructor) { | ||
export const sealed = (constructor) => { | ||
Object.seal(constructor); | ||
Object.seal(constructor.prototype); | ||
} | ||
exports.sealed = sealed; | ||
}; |
@@ -1,4 +0,11 @@ | ||
import * as decorators from "./decorators"; | ||
import * as mixins from "./mixins"; | ||
export { decorators, mixins, }; | ||
export * from "./api"; | ||
export * from "./assert"; | ||
export * from "./mixin"; | ||
export * from "./decorators/configurable"; | ||
export * from "./decorators/deprecated"; | ||
export * from "./decorators/nomixin"; | ||
export * from "./decorators/sealed"; | ||
export * from "./mixins/ienable"; | ||
export * from "./mixins/inotify"; | ||
export * from "./mixins/iterable"; | ||
export * from "./mixins/iwatch"; |
21
index.js
@@ -1,10 +0,11 @@ | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const decorators = require("./decorators"); | ||
exports.decorators = decorators; | ||
const mixins = require("./mixins"); | ||
exports.mixins = mixins; | ||
__export(require("./api")); | ||
export * from "./api"; | ||
export * from "./assert"; | ||
export * from "./mixin"; | ||
export * from "./decorators/configurable"; | ||
export * from "./decorators/deprecated"; | ||
export * from "./decorators/nomixin"; | ||
export * from "./decorators/sealed"; | ||
export * from "./mixins/ienable"; | ||
export * from "./mixins/inotify"; | ||
export * from "./mixins/iterable"; | ||
export * from "./mixins/iwatch"; |
@@ -13,2 +13,2 @@ /** | ||
*/ | ||
export declare function mixin(behaviour: any, sharedBehaviour?: {}): (clazz: any) => any; | ||
export declare const mixin: (behaviour: any, sharedBehaviour?: {}) => (clazz: any) => any; |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
@@ -15,3 +13,3 @@ * Class behavior mixin based on: | ||
*/ | ||
function mixin(behaviour, sharedBehaviour = {}) { | ||
export const mixin = (behaviour, sharedBehaviour = {}) => { | ||
const instanceKeys = Reflect.ownKeys(behaviour); | ||
@@ -44,3 +42,2 @@ const sharedKeys = Reflect.ownKeys(sharedBehaviour); | ||
return _mixin; | ||
} | ||
exports.mixin = mixin; | ||
}; |
@@ -7,2 +7,2 @@ /** | ||
*/ | ||
export declare const IEnable: (clazz: any) => any; | ||
export declare const IEnableMixin: (clazz: any) => any; |
@@ -1,5 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const api = require("../api"); | ||
const mixin_1 = require("../mixin"); | ||
import { EVENT_DISABLE, EVENT_ENABLE } from "../api"; | ||
import { mixin } from "../mixin"; | ||
/** | ||
@@ -11,3 +9,3 @@ * Mixin class decorator, injects IEnable default implementation, incl. | ||
*/ | ||
exports.IEnable = mixin_1.mixin({ | ||
export const IEnableMixin = mixin({ | ||
_enabled: true, | ||
@@ -20,3 +18,3 @@ isEnabled() { | ||
if (this.notify) { | ||
this.notify({ id: api.EVENT_ENABLE, target: this }); | ||
this.notify({ id: EVENT_ENABLE, target: this }); | ||
} | ||
@@ -27,3 +25,3 @@ }, | ||
if (this.notify) { | ||
this.notify({ id: api.EVENT_DISABLE, target: this }); | ||
this.notify({ id: EVENT_DISABLE, target: this }); | ||
} | ||
@@ -30,0 +28,0 @@ }, |
@@ -1,3 +0,3 @@ | ||
import * as api from "../api"; | ||
export declare function inotify_dispatch(listeners: any[][], e: api.Event): void; | ||
import { Event } from "../api"; | ||
export declare const inotify_dispatch: (listeners: any[][], e: Event) => void; | ||
/** | ||
@@ -8,2 +8,2 @@ * Mixin class decorator, injects INotify default implementation, incl. | ||
*/ | ||
export declare const INotify: (clazz: any) => any; | ||
export declare const INotifyMixin: (clazz: any) => any; |
@@ -1,11 +0,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const api = require("../api"); | ||
const mixin_1 = require("../mixin"); | ||
function inotify_dispatch(listeners, e) { | ||
import { EVENT_ALL } from "../api"; | ||
import { mixin } from "../mixin"; | ||
export const inotify_dispatch = (listeners, e) => { | ||
if (!listeners) | ||
return; | ||
const n = listeners.length; | ||
let i = 0, l; | ||
for (i = 0; i < n; i++) { | ||
for (let i = 0, n = listeners.length, l; i < n; i++) { | ||
l = listeners[i]; | ||
@@ -17,4 +13,3 @@ l[0].call(l[1], e); | ||
} | ||
} | ||
exports.inotify_dispatch = inotify_dispatch; | ||
}; | ||
/** | ||
@@ -25,3 +20,3 @@ * Mixin class decorator, injects INotify default implementation, incl. | ||
*/ | ||
exports.INotify = mixin_1.mixin({ | ||
export const INotifyMixin = mixin({ | ||
addListener(id, fn, scope) { | ||
@@ -56,3 +51,3 @@ let l = (this._listeners = this._listeners || {})[id]; | ||
inotify_dispatch(this._listeners[e.id], e); | ||
inotify_dispatch(this._listeners[api.EVENT_ALL], e); | ||
inotify_dispatch(this._listeners[EVENT_ALL], e); | ||
}, | ||
@@ -59,0 +54,0 @@ __listener(listeners, f, scope) { |
@@ -1,1 +0,1 @@ | ||
export declare function iterable(prop: PropertyKey): (clazz: any) => any; | ||
export declare const iterable: (prop: string | number | symbol) => (clazz: any) => any; |
@@ -1,9 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const mixin_1 = require("../mixin"); | ||
function iterable(prop) { | ||
return mixin_1.mixin({ | ||
*[Symbol.iterator]() { yield* (this[prop]); }, | ||
}); | ||
} | ||
exports.iterable = iterable; | ||
import { mixin } from "../mixin"; | ||
export const iterable = (prop) => mixin({ | ||
*[Symbol.iterator]() { yield* (this[prop]); }, | ||
}); |
@@ -1,1 +0,1 @@ | ||
export declare const IWatch: (clazz: any) => any; | ||
export declare const IWatchMixin: (clazz: any) => any; |
@@ -1,5 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const mixin_1 = require("../mixin"); | ||
exports.IWatch = mixin_1.mixin({ | ||
import { mixin } from "../mixin"; | ||
export const IWatchMixin = mixin({ | ||
addWatch(id, fn) { | ||
@@ -6,0 +4,0 @@ this._watches = this._watches || {}; |
{ | ||
"name": "@thi.ng/api", | ||
"version": "4.2.4", | ||
"version": "5.0.0", | ||
"description": "Common, generic types & interfaces for thi.ng projects", | ||
"main": "./index.js", | ||
"module": "./index.js", | ||
"main": "./lib/index.js", | ||
"umd:main": "./lib/index.umd.js", | ||
"typings": "./index.d.ts", | ||
@@ -15,8 +17,10 @@ "repository": { | ||
"scripts": { | ||
"build": "yarn clean && tsc --declaration", | ||
"clean": "rm -rf *.js *.d.ts .nyc_output build coverage doc decorators mixins", | ||
"build": "yarn clean && yarn build:es6 && yarn build:bundle", | ||
"build:es6": "tsc --declaration", | ||
"build:bundle": "../../scripts/bundle-module api errors", | ||
"test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", | ||
"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 src", | ||
"pub": "yarn build && yarn publish --access public", | ||
"test": "rm -rf build && tsc -p test && nyc mocha build/test/*.js" | ||
"pub": "yarn build && yarn publish --access public" | ||
}, | ||
@@ -28,7 +32,7 @@ "devDependencies": { | ||
"nyc": "^13.1.0", | ||
"typedoc": "^0.13.0", | ||
"typedoc": "^0.14.0", | ||
"typescript": "^3.2.2" | ||
}, | ||
"dependencies": { | ||
"@thi.ng/errors": "^0.1.12" | ||
"@thi.ng/errors": "^1.0.0" | ||
}, | ||
@@ -48,3 +52,11 @@ "keywords": [ | ||
}, | ||
"gitHead": "159ce8f6b1d2dad1e12f2ba3f4f7b60d1623acee" | ||
"browserslist": [ | ||
"since 2018-07" | ||
], | ||
"browser": { | ||
"process": false, | ||
"setTimeout": false | ||
}, | ||
"sideEffects": false, | ||
"gitHead": "348e7303b8b4d2749a02dd43e3f78d711242e4fe" | ||
} |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
68836
32
1099
4
+ Added@thi.ng/errors@1.3.4(transitive)
- Removed@thi.ng/errors@0.1.12(transitive)
Updated@thi.ng/errors@^1.0.0