Socket
Socket
Sign inDemoInstall

mobservable

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobservable - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

14

dist/mobservable.js

@@ -506,7 +506,13 @@ /**

ObservableArray.prototype.values = function () {
this.dependencyState.notifyObserved();
return this._values.slice();
};
ObservableArray.prototype.toJSON = function () {
this.dependencyState.notifyObserved();
return this._values.slice();
};
ObservableArray.prototype.clone = function () {
this.dependencyState.notifyObserved();
return new ObservableArray(this._values);
};
ObservableArray.prototype.splice = function (index, deleteCount) {

@@ -549,2 +555,8 @@ var newItems = [];

};
ObservableArray.prototype.reverse = function () {
return this.replace(this._values.reverse());
};
ObservableArray.prototype.sort = function (compareFn) {
return this.replace(this._values.sort.apply(this._values, arguments));
};
ObservableArray.prototype.toString = function () { return this.wrapReadFunction("toString", arguments); };

@@ -554,5 +566,3 @@ ObservableArray.prototype.toLocaleString = function () { return this.wrapReadFunction("toLocaleString", arguments); };

ObservableArray.prototype.join = function (separator) { return this.wrapReadFunction("join", arguments); };
ObservableArray.prototype.reverse = function () { return this.wrapReadFunction("reverse", arguments); };
ObservableArray.prototype.slice = function (start, end) { return this.wrapReadFunction("slice", arguments); };
ObservableArray.prototype.sort = function (compareFn) { return this.wrapReadFunction("sort", arguments); };
ObservableArray.prototype.indexOf = function (searchElement, fromIndex) { return this.wrapReadFunction("indexOf", arguments); };

@@ -559,0 +569,0 @@ ObservableArray.prototype.lastIndexOf = function (searchElement, fromIndex) { return this.wrapReadFunction("lastIndexOf", arguments); };

@@ -25,3 +25,3 @@ declare module "mobservable" {

export var SimpleEventEmitter: new() => ISimpleEventEmitter;
export var SimpleEventEmitter: new() => ISimpleEventEmitter;

@@ -33,7 +33,23 @@ interface IObservableArray<T> extends Array<T> {

spliceWithArray(index:number, deleteCount?:number, newItems?:T[]):T[];
observe(listener:()=>void, fireImmediately?:boolean):Lambda;
observe(listener:(changeData:IArrayChange<T>|IArraySplice<T>)=>void, fireImmediately?:boolean):Lambda;
clear(): T[];
replace(newItems:T[]);
values(): T[];
clone(): IObservableArray<T>;
}
interface IArrayChange<T> {
type: string; // Always: 'update'
object: IObservableArray<T>;
index: number;
oldValue: T;
}
interface IArraySplice<T> {
type: string; // Always: 'splice'
object: IObservableArray<T>;
index: number;
removed: T[];
addedCount: number;
}

@@ -40,0 +56,0 @@ interface ISimpleEventEmitter {

30

mobservable.ts

@@ -535,3 +535,3 @@ /**

[n: number]: T;
private _values: T[];

@@ -551,3 +551,3 @@ private dependencyState:DNode;

}
get length():number {

@@ -557,3 +557,3 @@ this.dependencyState.notifyObserved();

}
set length(newLength:number) {

@@ -572,3 +572,3 @@ if (typeof newLength !== "number" || newLength < 0)

// adds / removes the necessary numeric properties to this object
private updateLength(oldLength:number, delta:number) {
private updateLength(oldLength:number, delta:number) {
if (delta < 0)

@@ -650,2 +650,3 @@ for(var i = oldLength + delta; i < oldLength; i++)

values(): T[] {
this.dependencyState.notifyObserved();
return this._values.slice();

@@ -655,5 +656,11 @@ }

toJSON(): T[] {
this.dependencyState.notifyObserved();
return this._values.slice();
}
clone(): ObservableArray<T> {
this.dependencyState.notifyObserved();
return new ObservableArray<T>(this._values);
}
/*

@@ -692,2 +699,9 @@ functions that do alter the internal structure of the array, from lib.es6.d.ts

reverse():T[] {
return this.replace(this._values.reverse());
}
sort(compareFn?: (a: T, b: T) => number): T[] {
return this.replace(this._values.sort.apply(this._values, arguments));
}
/*

@@ -701,5 +715,3 @@ functions that do not alter the array, from lib.es6.d.ts

join(separator?: string): string { return this.wrapReadFunction<string>("join", arguments); }
reverse():T[] { return this.wrapReadFunction<T[]>("reverse", arguments); }
slice(start?: number, end?: number): T[] { return this.wrapReadFunction<T[]>("slice", arguments); }
sort(compareFn?: (a: T, b: T) => number): T[] { return this.wrapReadFunction<T[]>("sort", arguments); }
indexOf(searchElement: T, fromIndex?: number): number { return this.wrapReadFunction<number>("indexOf", arguments); }

@@ -726,3 +738,3 @@ lastIndexOf(searchElement: T, fromIndex?: number): number { return this.wrapReadFunction<number>("lastIndexOf", arguments); }

static ENUMERABLE_PROPS = [];
static createArrayBufferItem(index:number) {

@@ -757,6 +769,6 @@ var prop = {

}
static reserveArrayBuffer(max:number) {
for (var index = ObservableArray.OBSERVABLE_ARRAY_BUFFER_SIZE; index <= max; index++)
ObservableArray.createArrayBufferItem(index);
ObservableArray.createArrayBufferItem(index);
ObservableArray.OBSERVABLE_ARRAY_BUFFER_SIZE = max;

@@ -763,0 +775,0 @@ }

{
"name": "mobservable",
"version": "0.3.1",
"version": "0.3.2",
"description": "Changes are coming! Small library for creating observable properties en functions",

@@ -5,0 +5,0 @@ "main": "dist/mobservable.js",

@@ -19,3 +19,2 @@

* ~~process remaining optimizations / todo's, document code~~
* test browser compatibility?
* coverage tests

@@ -31,2 +30,3 @@ * minified version

* examples
* introduce extend / properties / defineProperties
* describe properties in readme:

@@ -41,3 +41,3 @@ - synchronous updates

* optimizations
- pass compute function into DNode in computed observable
- ~~pass compute function into DNode in computed observable~~
- computable's without observers should stay 'awake' after a computation (e.g. being inspected by .get),

@@ -47,14 +47,26 @@ but then go to sleep if one of its dependencies has changed, so that subsequent reads on a computable are cheap even if there are no observers

- check if somewhere an array is filled that could be preallocate
- array: recycle properties (or not)
- look into defineProperties / making property creating faster (especially arrays)
- ~~array: recycle properties (or not)~~
- ~~look into defineProperties / making property creating faster (especially arrays)~~
- ~~count stale dependencies, instead of looping each time whether all dependencies are ready again.~~
- collapse stale / ready notifications whenever possible
- find unmodifyable empty lists / objects and put in var
- heuristic to make computables non-lazy if used frequently (something like, in computable, if (this.lazyReads > this.computesWithoutObservers) then never-go-to-sleep)
* make sure array properties are read only
* License
- ~~find unmodifyable empty lists / objects and put in var~~
- ~~heuristic to make computables non-lazy if used frequently (something like, in computable, if (this.lazyReads > this.computesWithoutObservers) then never-go-to-sleep)~~
- combine multiple adds to array during batch into single splice
- verify that combine multiple assignments to property during batch are combined into singleupdate
- verify that multiple computations schedulings during batch result in single computation
* ~~make sure array properties are read only~~
0.4
* License
* implement array.sort & reverse properly, they do change the array
* drop mobservable.onReady / onceReady?
* clean up / clarify properties / annotations code
* drop initializeObservableProperty/ies
* introduce .props(target, prop, value), .props(props), .props(target, ...props)
* use disposable like RxJs?
0.5
* Introduce mobservable.object(data) that creates observable properties and an observe method.
* react components
* should arrays trigger a notify observed for methods like reverse, sort, values, json etc? -> they change the internal structure, so that seems to be weird

@@ -61,0 +73,0 @@ 0.5

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