mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-10 11:40:16 +08:00
Merge branch 'master' into rename-repo-url
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/// <reference path="observe-js.d.ts" />
|
||||
|
||||
module observejs {
|
||||
namespace observejs {
|
||||
|
||||
function Test_PathObserver() {
|
||||
var obj = { foo: { bar: 'baz' } };
|
||||
@@ -108,4 +108,4 @@ module observejs {
|
||||
transform.deliver(); // 'new: 14, old: 6'
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+53
-53
@@ -3,12 +3,12 @@
|
||||
// Definitions by: Oliver Herrmann <https://github.com/herrmanno/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module observejs {
|
||||
|
||||
declare namespace observejs {
|
||||
|
||||
/*----------------------
|
||||
Observable
|
||||
----------------------*/
|
||||
|
||||
|
||||
interface Observable {
|
||||
/**
|
||||
* Begins observation.
|
||||
@@ -21,23 +21,23 @@ declare module observejs {
|
||||
* Report any changes now (does nothing if there are no changes to report).
|
||||
*/
|
||||
deliver(): void
|
||||
|
||||
|
||||
/**
|
||||
* If there are changes to report, ignore them. Returns the current value of the observation.
|
||||
*/
|
||||
discardChanges():void
|
||||
|
||||
|
||||
/**
|
||||
* Ends observation. Frees resources and drops references to observed objects.
|
||||
*/
|
||||
close():void
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------
|
||||
PathObserver
|
||||
----------------------*/
|
||||
|
||||
|
||||
interface PathObserver_static {
|
||||
/**
|
||||
* Constructor
|
||||
@@ -47,7 +47,7 @@ declare module observejs {
|
||||
*/
|
||||
new(receiver:any, path:string, defaultValue?:any): PathObserver_instance
|
||||
}
|
||||
|
||||
|
||||
interface PathObserver_instance extends Observable {
|
||||
/**
|
||||
* sets the observed value without notifying about the change.
|
||||
@@ -55,43 +55,43 @@ declare module observejs {
|
||||
*/
|
||||
setValue(value:any): void
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Observes a "value-at-a-path" from a given object:
|
||||
* Observes a "value-at-a-path" from a given object:
|
||||
*/
|
||||
var PathObserver: PathObserver_static
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------
|
||||
ArrayObserver
|
||||
----------------------*/
|
||||
|
||||
|
||||
interface splice {
|
||||
|
||||
|
||||
/**
|
||||
* the index position that the change occured
|
||||
*/
|
||||
index:number
|
||||
|
||||
|
||||
/**
|
||||
* an array of values representing the sequence of removed elements
|
||||
*/
|
||||
removed: Array<any>
|
||||
|
||||
|
||||
/**
|
||||
* the number of element which were inserted
|
||||
* the number of element which were inserted
|
||||
*/
|
||||
addedCount:number
|
||||
}
|
||||
|
||||
|
||||
interface ArrayObserver_static {
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param receiver the target for observation
|
||||
*/
|
||||
new(receiver:Array<any>): ArrayObserver_instance
|
||||
|
||||
|
||||
/**
|
||||
* transforms a copy of an old state of an array into a copy of its current state.
|
||||
* @param previous array of old state
|
||||
@@ -100,86 +100,86 @@ declare module observejs {
|
||||
*/
|
||||
applySplices(previous:Array<any>, current:Array<any>, splices:Array<splice>):void
|
||||
}
|
||||
|
||||
|
||||
interface ArrayObserver_instance extends Observable {
|
||||
open(onChange:(splices:Array<splice>)=>any):void
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ArrayObserver observes the index-positions of an Array and reports changes as the minimal set of "splices" which would have had the same effect.
|
||||
*/
|
||||
var ArrayObserver: ArrayObserver_static
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------
|
||||
ObjectObserver
|
||||
----------------------*/
|
||||
|
||||
|
||||
interface Properties {
|
||||
[key:string]:any
|
||||
}
|
||||
|
||||
|
||||
interface ObjectObserver_static {
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param receiver the target for observation
|
||||
*/
|
||||
new(receiver:any): ObjectObserver_instance
|
||||
}
|
||||
|
||||
|
||||
interface ObjectObserver_instance extends Observable {
|
||||
open(onChange:(added:Properties, removed:Properties, changed:Properties, getOldValueFn:(property:string)=>any)=>any):void
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Observes the set of own-properties of an object and their values
|
||||
*/
|
||||
var ObjectObserver: ObjectObserver_static
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------
|
||||
CompounObserver
|
||||
----------------------*/
|
||||
|
||||
|
||||
interface CompoundObserver_static {
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
new(): CompoundObserver_instance
|
||||
}
|
||||
|
||||
|
||||
interface CompoundObserver_instance extends Observable {
|
||||
open(onChange:(newValues:Array<any>, oldValue:Array<any>)=>any):void
|
||||
|
||||
|
||||
/**
|
||||
* Adds the receivers property at the specified path to the list of observables.
|
||||
* @param receiver the target for observation
|
||||
* @param path specifies the paht to observe. If path === '' the receiver itself gets observed.
|
||||
*/
|
||||
addPath(receiver:any, path:string):void
|
||||
|
||||
|
||||
/**
|
||||
* Adds an Observer to the list of observables.
|
||||
*/
|
||||
addObserver(observer:Observable):void
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* CompoundObserver allows simultaneous observation of multiple paths and/or Observables.
|
||||
*/
|
||||
var CompoundObserver: CompoundObserver_static
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------
|
||||
ObserverTransform
|
||||
----------------------*/
|
||||
|
||||
|
||||
interface ObserverTransform_static {
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param observer the observer to transform
|
||||
@@ -187,7 +187,7 @@ declare module observejs {
|
||||
* @param setValue function that proxys setting a value
|
||||
*/
|
||||
new(observer:Observable, getValue:(value:any)=>any, setValue:(value:any)=>any): ObserverTransform_instance
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param observer the observer to transform
|
||||
@@ -195,7 +195,7 @@ declare module observejs {
|
||||
*/
|
||||
new(observer:Observable, valueFn:(values:Array<any>)=>any): ObserverTransform_instance
|
||||
}
|
||||
|
||||
|
||||
interface ObserverTransform_instance extends Observable {
|
||||
/**
|
||||
* sets the observed value without notifying about the change.
|
||||
@@ -203,26 +203,26 @@ declare module observejs {
|
||||
*/
|
||||
setValue(value:any): void
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* CompoundObserver allows simultaneous observation of multiple paths and/or Observables.
|
||||
*/
|
||||
var ObserverTransform: ObserverTransform_static
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------
|
||||
Path
|
||||
----------------------*/
|
||||
|
||||
|
||||
interface Path {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current value of the path from the provided object. If eval() is available,
|
||||
* a compiled getter will be used for better performance. Like PathObserver above, undefined
|
||||
* is returned unless you provide an overriding defaultValue.
|
||||
*/
|
||||
getValueFrom(object:any, defaultValue:any): any
|
||||
|
||||
|
||||
/**
|
||||
* Attempts to set the value of the path from the provided object. Returns true IFF the path
|
||||
* was reachable and set.
|
||||
@@ -238,7 +238,7 @@ declare module "observe-js" {
|
||||
var CompoundObserver: typeof observejs.CompoundObserver;
|
||||
var ObserverTransform: typeof observejs.ObserverTransform;
|
||||
var Path: observejs.Path;
|
||||
|
||||
|
||||
export {
|
||||
PathObserver,
|
||||
ArrayObserver,
|
||||
|
||||
Reference in New Issue
Block a user