@thi.ng/api
Advanced tools
Comparing version 3.0.1 to 4.0.0
208
api.d.ts
@@ -0,5 +1,46 @@ | ||
export declare const DEFAULT_EPS = 0.000001; | ||
export declare const EVENT_ALL = "*"; | ||
export declare const EVENT_ENABLE = "enable"; | ||
export declare const EVENT_DISABLE = "disable"; | ||
/** | ||
* Generic 2-element comparator function type alias. Must follow this | ||
* contract and return: | ||
* | ||
* - negative if `a < b` | ||
* - zero if `a == b` | ||
* - positive if `a > b` | ||
*/ | ||
export declare type Comparator<T> = (a: T, b: T) => number; | ||
/** | ||
* Event listener. | ||
*/ | ||
export declare type Listener = (e: Event) => void; | ||
/** | ||
* Lookup path for nested data structures. | ||
*/ | ||
export declare type Path = PropertyKey | PropertyKey[]; | ||
/** | ||
* Predicate function mapping given value to true/false. | ||
*/ | ||
export declare type Predicate<T> = (a: T) => boolean; | ||
/** | ||
* Predicate function mapping given args to true/false. | ||
*/ | ||
export declare type Predicate2<T> = (a: T, b: T) => boolean; | ||
/** | ||
* Higher order `Predicate` builder. Possibly stateful. | ||
*/ | ||
export declare type StatefulPredicate<T> = () => Predicate<T>; | ||
/** | ||
* Higher order `Predicate2` builder. Possibly stateful. | ||
*/ | ||
export declare type StatefulPredicate2<T> = () => Predicate2<T>; | ||
/** | ||
* Observer function for `IWatch` implementations. | ||
*/ | ||
export declare type Watch<T> = (id: string, oldState: T, newState: T) => void; | ||
/** | ||
* @param K key type | ||
* @param V value type | ||
* @param T imlementation type | ||
* @param T implementation type | ||
*/ | ||
@@ -12,11 +53,14 @@ export interface IAssociative<K, V, T> { | ||
} | ||
export interface IBind { | ||
/** | ||
* Generic resource binding methods. | ||
*/ | ||
export interface IBind<T> { | ||
/** | ||
* @returns true, if successful | ||
*/ | ||
bind(opt?: any): boolean; | ||
bind(opt: T): boolean; | ||
/** | ||
* @returns true, if successful | ||
*/ | ||
unbind(opt?: any): boolean; | ||
unbind(opt: T): boolean; | ||
} | ||
@@ -28,4 +72,4 @@ /** | ||
/** | ||
* An implementation's publically accessible backing array / ArrayBuffer | ||
* (usually a typed array instance). | ||
* An implementation's publicly accessible backing array / | ||
* ArrayBuffer (usually a typed array instance). | ||
*/ | ||
@@ -51,14 +95,5 @@ buffer: T; | ||
/** | ||
* Generic 2-element comparator function type alias. | ||
* Must follow this contract and return: | ||
* | ||
* - negative if `a < b` | ||
* - zero if `a == b` | ||
* - positive if `a > b` | ||
* Generic interface for collection types to check if a given value is | ||
* part of the collection. | ||
*/ | ||
export declare type Comparator<T> = (a: T, b: T) => number; | ||
/** | ||
* Generic interface for collection types to check if a given value | ||
* is part of the collection. | ||
*/ | ||
export interface IContains<T> { | ||
@@ -77,4 +112,4 @@ /** | ||
/** | ||
* Returns a copy of this instance. | ||
* Shallow or deep copies are implementation specific. | ||
* Returns a copy of this instance. Shallow or deep copies are | ||
* implementation specific. | ||
*/ | ||
@@ -104,3 +139,4 @@ copy(): T; | ||
/** | ||
* Returns an empty collection of same type (and possibly same config). | ||
* Returns an empty collection of same type (and possibly same | ||
* config). | ||
*/ | ||
@@ -110,6 +146,6 @@ empty(): T; | ||
/** | ||
* Interface to provide enabled/disabled functionality. | ||
* Also see `@IEnable` decorator mixin | ||
* Interface to provide enabled/disabled functionality. Also see | ||
* `@IEnable` decorator mixin | ||
*/ | ||
export interface IEnable { | ||
export interface IEnable<T> { | ||
isEnabled(): boolean; | ||
@@ -120,3 +156,3 @@ /** | ||
*/ | ||
disable(opts?: any): any; | ||
disable(opts: T): any; | ||
/** | ||
@@ -126,3 +162,3 @@ * Enables this entity. | ||
*/ | ||
enable(opts?: any): any; | ||
enable(opts: T): any; | ||
toggle?(): boolean; | ||
@@ -132,4 +168,4 @@ } | ||
/** | ||
* Returns `true` if this *value* is equivalent to `o`. | ||
* Also see `ICompare.compare` and `IHash.hash`. | ||
* Returns `true` if this *value* is equivalent to `o`. Also see | ||
* `ICompare.compare` and `IHash.hash`. | ||
* | ||
@@ -140,3 +176,2 @@ * @param o | ||
} | ||
export declare const DEFAULT_EPS = 0.000001; | ||
export interface IEqualsDelta<T> { | ||
@@ -157,9 +192,5 @@ /** | ||
} | ||
export declare const EVENT_ALL = "*"; | ||
export declare const EVENT_ENABLE = "enable"; | ||
export declare const EVENT_DISABLE = "disable"; | ||
export declare type Listener = (e: Event) => void; | ||
/** | ||
* Interface to provide event emitter functionality. | ||
* Also see `@INotify` decorator mixin | ||
* Interface to provide event emitter functionality. Also see `@INotify` | ||
* decorator mixin | ||
*/ | ||
@@ -176,4 +207,4 @@ export interface INotify { | ||
export interface IGet<K, V> { | ||
get(key: K, notfound?: any): V; | ||
getIn(key: K[], notfound?: any): V; | ||
get(key: K, notfound?: V): V; | ||
getIn(key: K[], notfound?: V): V; | ||
} | ||
@@ -185,18 +216,32 @@ /** | ||
/** | ||
* Returns a value's hash code. | ||
* The contract of this function is: If | ||
* `IEquiv.equiv` returns `true` two values, | ||
* their hash codes MUST also be equal. | ||
* Returns a value's hash code. The contract of this function is: If | ||
* `IEquiv.equiv` returns `true` for two values, their hash codes | ||
* MUST also be equal. | ||
*/ | ||
hash(): T; | ||
} | ||
/** | ||
* `id` property declaration. | ||
*/ | ||
export interface IID<T> { | ||
readonly id: T; | ||
} | ||
/** | ||
* Interface for collection types which can be accessed via numeric | ||
* index. | ||
*/ | ||
export interface IIndexed<T> { | ||
nth(i: number): T; | ||
nth(i: number, notfound: T): T; | ||
} | ||
/** | ||
* Interface for collections to obtain their element count. | ||
* Interface for collection types supporting addition of multiple | ||
* values. | ||
*/ | ||
export interface IInto<T> { | ||
into(coll: Iterable<T>): this; | ||
} | ||
/** | ||
* `length` property declaration for collections to obtain their element | ||
* count. | ||
*/ | ||
export interface ILength { | ||
@@ -206,10 +251,10 @@ readonly length: number; | ||
/** | ||
* Generic interface for types supporting metadata. | ||
* Implementations MUST exclude metadata from any comparisons, | ||
* equality checks & hashing. | ||
* Generic interface for types supporting metadata. Implementations MUST | ||
* exclude metadata from any comparisons, equality checks & hashing. | ||
*/ | ||
export interface IMeta<T> { | ||
__meta: any; | ||
meta(): any; | ||
/** | ||
* Returns a copy of the original value with given metadata attached. | ||
* Returns a copy of the original value with given metadata | ||
* attached. | ||
* | ||
@@ -226,6 +271,5 @@ * @param meta | ||
} | ||
export declare type Predicate<T> = (a: T) => boolean; | ||
export declare type Predicate2<T> = (a: T, b: T) => boolean; | ||
export declare type StatefulPredicate<T> = () => Predicate<T>; | ||
export declare type StatefulPredicate2<T> = () => Predicate2<T>; | ||
/** | ||
* Interface for types supported the release of internal resources. | ||
*/ | ||
export interface IRelease { | ||
@@ -235,11 +279,31 @@ release(opt?: any): boolean; | ||
/** | ||
* Generic interface for set collection types. | ||
* Generic interface for MUTABLE set collection types. | ||
* | ||
* @param T value type | ||
*/ | ||
export interface ISet<T> extends IInto<T> { | ||
/** | ||
* Conjoins/adds value `x` to set and returns true if `x` has been | ||
* added. | ||
* | ||
* @param x | ||
*/ | ||
conj(x: T): boolean; | ||
/** | ||
* Disjoins/removes value `x` from set and returns true if `x` has | ||
* been removed. | ||
* | ||
* @param x | ||
*/ | ||
disj(x: T): boolean; | ||
} | ||
/** | ||
* Generic interface for IMMUTABLE set collection types. | ||
* | ||
* @param V value type | ||
* @param T return or container type | ||
* @param T implementation type | ||
*/ | ||
export interface ISet<V, T> { | ||
export interface IImmutableSet<V, T> extends IInto<V> { | ||
/** | ||
* Conjoins/adds value `x` to set and returns updated set | ||
* (possibly mutable operation). | ||
* Conjoins/adds value `x` to set and returns updated set. | ||
* | ||
@@ -250,4 +314,3 @@ * @param x | ||
/** | ||
* Disjoins/removes value `x` from set and returns updated set | ||
* (possibly mutable operation). | ||
* Disjoins/removes value `x` from set and returns updated set. | ||
* | ||
@@ -259,4 +322,4 @@ * @param x | ||
/** | ||
* Generic interface for sequential collections implementing stack | ||
* functionality. | ||
* Generic interface for MUTABLE sequential collections implementing | ||
* stack functionality. | ||
* | ||
@@ -272,5 +335,21 @@ * @param V value type | ||
/** | ||
* Removes top-of-stack item and returns it. | ||
*/ | ||
pop(): V; | ||
push(x: V): T; | ||
} | ||
/** | ||
* Generic interface for IMMUTABLE sequential collections implementing | ||
* stack functionality. | ||
* | ||
* @param V value type | ||
* @param T return/container type | ||
*/ | ||
export interface IImmutableStack<V, T> { | ||
/** | ||
* Returns top-of-stack item. | ||
*/ | ||
peek(): V; | ||
/** | ||
* Returns collection w/ top-of-stack item removed. | ||
* It's implementation specific if this operation is | ||
* mutable or not. | ||
*/ | ||
@@ -280,3 +359,6 @@ pop(): T; | ||
} | ||
export declare type Watch<T> = (id: string, oldState: T, newState: T) => void; | ||
/** | ||
* Interface for types offering observers of internal value changes. | ||
* Also see `@IWatch` decorator mixin. | ||
*/ | ||
export interface IWatch<T> { | ||
@@ -283,0 +365,0 @@ addWatch(id: string, fn: Watch<T>): boolean; |
@@ -6,2 +6,24 @@ # Change Log | ||
<a name="4.0.0"></a> | ||
# [4.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@3.0.1...@thi.ng/api@4.0.0) (2018-05-12) | ||
### Code Refactoring | ||
* **api:** update interfaces, add docs ([9b38860](https://github.com/thi-ng/umbrella/commit/9b38860)) | ||
### BREAKING CHANGES | ||
* **api:** IBind, IEnable now include generics, | ||
update IIndexed, IMeta, ISet, IStack | ||
- add IInto | ||
- add IImmutableSet | ||
- add IImmutableStack | ||
- minor update IEnabled mixin | ||
<a name="3.0.1"></a> | ||
@@ -8,0 +30,0 @@ ## [3.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@3.0.0...@thi.ng/api@3.0.1) (2018-05-10) |
{ | ||
"name": "@thi.ng/api", | ||
"version": "3.0.1", | ||
"version": "4.0.0", | ||
"description": "Common, generic types & interfaces for thi.ng projects", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38448
711
188
1
3
1
38