Socket
Socket
Sign inDemoInstall

collections

Package Overview
Dependencies
Maintainers
5
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

collections - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

.editorconfig

6

CHANGES.md
## v1.2.2
- Vlad Alexandru Ionescu fixed a bug in dictionaries with single character keys.
- Optimizations for push to avoid creating unnecessary arrays through splice
- Fixes for a few regressions in listen and impacting Montage
## v1.2.0

@@ -3,0 +9,0 @@

2

dict.js

@@ -65,3 +65,3 @@ "use strict";

if (mangled in this.store) { // update
if (this.dispatchesBeforeMapChanges) {
if (this.dispatchesMapChanges) {
this.dispatchBeforeMapChange(key, this.store[mangled]);

@@ -68,0 +68,0 @@ }

@@ -25,3 +25,6 @@ "use strict";

this.getDefault = getDefault;
this.buckets = new this.Buckets(null, this.Bucket);
var self = this;
this.buckets = new this.Buckets(null, function getDefaultBucket() {
return new self.Bucket();
});
this.length = 0;

@@ -28,0 +31,0 @@ this.addEach(values);

@@ -8,2 +8,4 @@ "use strict";

GenericCollection.EmptyArray = Object.freeze([]);
GenericCollection.prototype.addEach = function (values) {

@@ -10,0 +12,0 @@ if (values && Object(values) === values) {

@@ -0,21 +1,31 @@

3-clause BSD license
====================
Copyright 2012 Kristopher Michael Kowal. All rights reserved.
Copyright 2012-2014 Motorola Mobility LLC, Montage Studio Inc, and contributors.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Montage nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
/*
Based in part on observable arrays from Motorola Mobility’s Montage
Copyright (c) 2012, Motorola Mobility LLC. All Rights Reserved.
3-Clause BSD License
https://github.com/motorola-mobility/montage/blob/master/LICENSE.md
*/
Based in part on observable arrays from Motorola Mobility’s Montage
Copyright (c) 2012, Motorola Mobility LLC. All Rights Reserved.
3-Clause BSD License
https://github.com/motorola-mobility/montage/blob/master/LICENSE.md
*/
/*
This module is responsible for observing changes to owned properties of
objects and changes to the content of arrays caused by method calls.
The interface for observing array content changes establishes the methods
necessary for any collection with observable content.
*/
This module is responsible for observing changes to owned properties of
objects and changes to the content of arrays caused by method calls.
The interface for observing array content changes establishes the methods
necessary for any collection with observable content.
*/
require("../shim");
var List = require("../list");
var WeakMap = require("weak-map");
var PropertyChanges = require("./property-changes");
var RangeChanges = require("./range-changes");
var MapChanges = require("./map-changes");
var array_splice = Array.prototype.splice;

@@ -27,5 +25,4 @@ var array_slice = Array.prototype.slice;

var array_swap = Array.prototype.swap;
var array_push = Array.prototype.push;
var EMPTY_ARRAY = [];
// use different strategies for making arrays observable between Internet

@@ -64,2 +61,11 @@ // Explorer and other browsers.

defineEach(PropertyChanges.prototype);
//This is a no-op test in property-changes.js - PropertyChanges.prototype.makePropertyObservable, so might as well not pay the price every time....
Object.defineProperty(Array.prototype, "makePropertyObservable", {
value: function(){},
writable: true,
configurable: true,
enumerable: false
});
defineEach(RangeChanges.prototype);

@@ -97,8 +103,8 @@ defineEach(MapChanges.prototype);

value: function sort() {
var index, length;
// dispatch before change events
this.dispatchBeforeRangeChange(this, this, 0);
for (var i = 0; i < this.length; i++) {
PropertyChanges.dispatchBeforeOwnPropertyChange(this, i, this[i]);
this.dispatchBeforeMapChange(i, this[i]);
for (index = 0, length = this.length; index < length; index++) {
PropertyChanges.dispatchBeforeOwnPropertyChange(this, index, this[index]);
this.dispatchBeforeMapChange(index, this[index]);
}

@@ -110,5 +116,5 @@

// dispatch after change events
for (var i = 0; i < this.length; i++) {
PropertyChanges.dispatchOwnPropertyChange(this, i, this[i]);
this.dispatchMapChange(i, this[i]);
for (index = 0, length = this.length; index < length; index++) {
PropertyChanges.dispatchOwnPropertyChange(this, index, this[index]);
this.dispatchMapChange(index, this[index]);
}

@@ -123,4 +129,23 @@ this.dispatchRangeChange(this, this, 0);

_dispatchBeforeOwnPropertyChange: {
value: function _dispatchBeforeOwnPropertyChange(start, length) {
for (var i = start, countI = start+length; i < countI; i++) {
PropertyChanges.dispatchBeforeOwnPropertyChange(this, i, this[i]);
this.dispatchBeforeMapChange(i, this[i]);
}
}
},
_dispatchOwnPropertyChange: {
value: function _dispatchOwnPropertyChange(start, length) {
for (var i = start, countI = start+length; i < countI; i++) {
this.dispatchOwnPropertyChange(i, this[i]);
this.dispatchMapChange(i, this[i]);
}
}
},
swap: {
value: function swap(start, length, plus) {
var hasOwnPropertyChangeDescriptor, i, j;
if (plus) {

@@ -131,3 +156,3 @@ if (!Array.isArray(plus)) {

} else {
plus = EMPTY_ARRAY;
plus = Array.empty;
}

@@ -140,3 +165,3 @@

var newPlus = Array(holes + plus.length);
for (var i = 0, j = holes; i < plus.length; i++, j++) {
for (i = 0, j = holes; i < plus.length; i++, j++) {
if (i in plus) {

@@ -157,3 +182,3 @@ newPlus[j] = plus[i];

}
minus = EMPTY_ARRAY;
minus = Array.empty;
} else {

@@ -173,14 +198,8 @@ minus = array_slice.call(this, start, start + length);

if (diff === 0) { // substring replacement
for (var i = start; i < start + plus.length; i++) {
PropertyChanges.dispatchBeforeOwnPropertyChange(this, i, this[i]);
this.dispatchBeforeMapChange(i, this[i]);
}
} else if (PropertyChanges.hasOwnPropertyChangeDescriptor(this)) {
this._dispatchBeforeOwnPropertyChange(start, plus.length);
} else if ((hasOwnPropertyChangeDescriptor = PropertyChanges.hasOwnPropertyChangeDescriptor(this))) {
// all subsequent values changed or shifted.
// avoid (longest - start) long walks if there are no
// registered descriptors.
for (var i = start; i < longest; i++) {
PropertyChanges.dispatchBeforeOwnPropertyChange(this, i, this[i]);
this.dispatchBeforeMapChange(i, this[i]);
}
this._dispatchBeforeOwnPropertyChange(start, longest-start);
}

@@ -196,18 +215,12 @@

if (diff === 0) { // substring replacement
for (var i = start; i < start + plus.length; i++) {
PropertyChanges.dispatchOwnPropertyChange(this, i, this[i]);
this.dispatchMapChange(i, this[i]);
}
} else if (PropertyChanges.hasOwnPropertyChangeDescriptor(this)) {
this._dispatchOwnPropertyChange(start,plus.length);
} else if (hasOwnPropertyChangeDescriptor) {
// all subsequent values changed or shifted.
// avoid (longest - start) long walks if there are no
// registered descriptors.
for (var i = start; i < longest; i++) {
PropertyChanges.dispatchOwnPropertyChange(this, i, this[i]);
this.dispatchMapChange(i, this[i]);
}
this._dispatchOwnPropertyChange(start,longest-start);
}
this.dispatchRangeChange(plus, minus, start);
if (diff) {
PropertyChanges.dispatchOwnPropertyChange(this, "length", this.length);
this.dispatchOwnPropertyChange("length", this.length);
}

@@ -267,8 +280,28 @@

value: function push(arg) {
if (arguments.length === 1) {
return this.splice(this.length, 0, arg);
} else {
var args = array_slice.call(arguments);
return this.swap(this.length, 0, args);
var start = this.length,
addedCount = arguments.length,
argArray,
hasOwnPropertyChangeDescriptor;
argArray = addedCount === 1 ? [arguments[0]] : Array.apply(null, arguments);
if(addedCount > 0) {
PropertyChanges.dispatchBeforeOwnPropertyChange(this, "length", start);
this.dispatchBeforeRangeChange(argArray, Array.empty, start);
if(hasOwnPropertyChangeDescriptor = PropertyChanges.hasOwnPropertyChangeDescriptor(this)) {
this._dispatchBeforeOwnPropertyChange(start, addedCount);
}
}
array_push.apply(this,arguments);
if (addedCount > 0) {
if (hasOwnPropertyChangeDescriptor) {
this._dispatchOwnPropertyChange(start,addedCount);
}
this.dispatchRangeChange(argArray,Array.empty, start);
this.dispatchOwnPropertyChange("length", this.length);
}
},

@@ -303,2 +336,3 @@ writable: true,

var ChangeDispatchArray = Object.create(Array.prototype, observableArrayProperties);
exports.observableArrayProperties = observableArrayProperties;

@@ -125,3 +125,3 @@ /*

return function cancelOwnPropertyChangeListener() {
PropertyChanges.removeOwnPropertyChangeListener(self, key, listener, beforeChange);
PropertyChanges.removeOwnPropertyChangeListener(self, key, listeners.current, beforeChange);
self = null;

@@ -171,2 +171,4 @@ };

if (listeners.length === 0) return;
try {

@@ -189,6 +191,7 @@ // dispatch to each listener

}
for (var index = 0, length = active.length; index < length; index++) {
var listener = active[index];
for (var i = 0, length = active.length; i < length; i++) {
var listener = active[i];
if (current.indexOf(listener) < 0) {
return;
//This is fixing the issue causing a regression in Montage's repetition
continue;
}

@@ -221,3 +224,3 @@ var thisp = listener;

if (!Object.isExtensible(this, key)) {
if (!Object.isExtensible(this)) {
throw new Error("Can't make property " + JSON.stringify(key) + " observable on " + this + " because object is not extensible");

@@ -231,3 +234,3 @@ }

state = {};
if (Object.isExtensible(this, "__state__")) {
if (Object.isExtensible(this)) {
Object.defineProperty(this, "__state__", {

@@ -246,3 +249,3 @@ value: state,

Object.defineProperty(this, "__overriddenPropertyDescriptors__", {
value: {},
value: overriddenPropertyDescriptors,
enumerable: false,

@@ -265,3 +268,2 @@ writable: true,

var attached = this;
var formerDescriptor = Object.getOwnPropertyDescriptor(attached, key);
do {

@@ -268,0 +270,0 @@ overriddenDescriptor = Object.getOwnPropertyDescriptor(attached, key);

{
"name": "collections",
"version": "1.2.1",
"version": "1.2.2",
"description": "data structures with idiomatic JavaScript collection interfaces",

@@ -31,6 +31,6 @@ "homepage": "http://www.collectionsjs.com",

"dependencies": {
"weak-map": "1.0.0"
"weak-map": "~1.0.x"
},
"devDependencies": {
"jasmine-node": ">=1.13.1 <1.14.0",
"jasmine-node": "~1.14.x",
"istanbul": "*",

@@ -37,0 +37,0 @@ "opener": "*"

@@ -234,6 +234,8 @@ "use strict";

define("clear", function () {
this.length = 0;
return this;
});
if (!Array.prototype.clear) {
define("clear", function () {
this.length = 0;
return this;
});
}

@@ -240,0 +242,0 @@ define("compare", function (that, compare) {

@@ -266,6 +266,7 @@ "use strict";

this.array.splice(index, length);
this.addEach(plus);
this.length -= minus.length;
if (this.dispatchesRangeChanges) {
this.dispatchRangeChange(plus, minus, index);
this.dispatchRangeChange([], minus, index);
}
this.addEach(plus);
return minus;

@@ -272,0 +273,0 @@ };

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