Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

can-list

Package Overview
Dependencies
Maintainers
8
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-list - npm Package Compare versions

Comparing version 4.0.0-pre.2 to 4.0.0-pre.3

9

can-list_test.js

@@ -365,3 +365,2 @@ var List = require('can-list');

});
sliced.start();

@@ -374,3 +373,2 @@ var joined = new Observation(function(){

});
joined.start();

@@ -482,5 +480,8 @@

canReflect.onKeysRemoved(b, handler);
QUnit.ok(b.__bindEvents.add, "add handler added");
QUnit.ok(b.__bindEvents.remove, "remove handler added");
var handlers = b[canSymbol.for("can.meta")].handlers;
QUnit.ok(handlers.get(["add"]).length, "add handler added");
QUnit.ok(handlers.get(["remove"]).length, "remove handler added");
b.push("quux");

@@ -487,0 +488,0 @@

/* jshint -W079 */
require('can-event');
var namespace = require('can-namespace');

@@ -8,4 +6,4 @@ var Map = require('can-map');

var mapHelpers = require('can-map/map-helpers');
var canBatch = require('can-event/batch/batch');
var canEvent = require('can-event');
var queues = require('can-queues');
var canEvent = require('can-event-queue');
var Observation = require('can-observation');

@@ -49,72 +47,6 @@

/**
* @add can.List
*/
var List = Map.extend(
/**
* @static
*/
{
/**
* @property {can.Map} can.List.Map
*
* @description Specify the Map type used to make objects added to this list observable.
*
* @option {can.Map} When objects are added to a can.List, those objects are
* converted into can.Map instances. For example:
*
* var list = new can.List();
* list.push({name: "Justin"});
*
* var map = list.attr(0);
* map.attr("name") //-> "Justin"
*
* By changing [can.List.Map], you can specify a different type of Map instance to
* create. For example:
*
* var User = can.Map.extend({
* fullName: function(){
* return this.attr("first")+" "+this.attr("last")
* }
* });
*
* User.List = can.List.extend({
* Map: User
* }, {});
*
* var list = new User.List();
* list.push({first: "Justin", last: "Meyer"});
*
* var user = list.attr(0);
* user.fullName() //-> "Justin Meyer"
*
*
*
*/
Map: Map
/**
* @function can.Map.extend
*
* @signature `can.List.extend([name,] [staticProperties,] instanceProperties)`
*
* Creates a new extended constructor function. Learn more at [can.Construct.extend].
*
* @param {String} [name] If provided, adds the extened List constructor function
* to the window at the given name.
*
* @param {Object} [staticProperties] Properties and methods
* directly on the constructor function. The most common property to set is [can.List.Map].
*
* @param {Object} [instanceProperties] Properties and methods on instances of this list type.
*
* @body
*
* ## Use
*
*
*/
},
/**
* @prototype
*/
{

@@ -231,103 +163,2 @@ setup: function (instances, options) {

},
/**
* @function can.List.prototype.each each
* @description Call a function on each element of a List.
* @signature `list.each( callback(item, index) )`
*
* `each` iterates through the List, calling a function
* for each element.
*
* @param {function(*, Number)} callback the function to call for each element
* The value and index of each element will be passed as the first and second
* arguments, respectively, to the callback. If the callback returns false,
* the loop will stop. The callback is not invoked for List elements that were
* never initialized.
*
* @return {can.List} this List, for chaining
*
* @body
* ```
* var i = 0;
* new can.List([1, 10, 100]).each(function(element, index) {
* i += element;
* });
*
* i; // 111
*
* i = 0;
* new can.List([1, 10, 100]).each(function(element, index) {
* i += element;
* if(index >= 1) {
* return false;
* }
* });
*
* i; // 11
* ```
*/
//
/**
* @function can.List.prototype.splice splice
* @description Insert and remove elements from a List.
* @signature `list.splice(index[, howMany[, ...newElements]])`
* @param {Number} index where to start removing or inserting elements
*
* @param {Number} [howMany] the number of elements to remove
* If _howMany_ is not provided, `splice` will remove all elements from `index` to the end of the List.
*
* @param {*} newElements elements to insert into the List
*
* @return {Array} the elements removed by `splice`
*
* @body
* `splice` lets you remove elements from and insert elements into a List.
*
* This example demonstrates how to do surgery on a list of numbers:
*
* ```
* var list = new can.List([0, 1, 2, 3]);
*
* // starting at index 2, remove one element and insert 'Alice' and 'Bob':
* list.splice(2, 1, 'Alice', 'Bob');
* list.attr(); // [0, 1, 'Alice', 'Bob', 3]
* ```
*
* ## Events
*
* `splice` causes the List it's called on to emit _change_ events,
* _add_ events, _remove_ events, and _length_ events. If there are
* any elements to remove, a _change_ event, a _remove_ event, and a
* _length_ event will be fired. If there are any elements to insert, a
* separate _change_ event, an _add_ event, and a separate _length_ event
* will be fired.
*
* This slightly-modified version of the above example should help
* make it clear how `splice` causes events to be emitted:
*
* ```
* var list = new can.List(['a', 'b', 'c', 'd']);
* list.bind('change', function(ev, attr, how, newVals, oldVals) {
* console.log('change: ' + attr + ', ' + how + ', ' + newVals + ', ' + oldVals);
* });
* list.bind('add', function(ev, newVals, where) {
* console.log('add: ' + newVals + ', ' + where);
* });
* list.bind('remove', function(ev, oldVals, where) {
* console.log('remove: ' + oldVals + ', ' + where);
* });
* list.bind('length', function(ev, length) {
* console.log('length: ' + length + ', ' + this.attr());
* });
*
* // starting at index 2, remove one element and insert 'Alice' and 'Bob':
* list.splice(2, 1, 'Alice', 'Bob'); // change: 2, 'remove', undefined, ['c']
* // remove: ['c'], 2
* // length: 5, ['a', 'b', 'Alice', 'Bob', 'd']
* // change: 2, 'add', ['Alice', 'Bob'], ['c']
* // add: ['Alice', 'Bob'], 2
* // length: 5, ['a', 'b', 'Alice', 'Bob', 'd']
* ```
*
* More information about binding to these events can be found under [can.List.attr attr].
*/
splice: function (index, howMany) {

@@ -372,3 +203,3 @@ var args = makeArray(arguments),

canBatch.start();
queues.batch.start();
if (howMany > 0) {

@@ -384,3 +215,3 @@ // tears down bubbling

}
canBatch.stop();
queues.batch.stop();
return removed;

@@ -399,3 +230,4 @@ }

/**
* @function can.List.prototype.push push
* @function can-list.prototype.push push
* @parent can-list.prototype
* @description Add elements to the end of a list.

@@ -414,3 +246,3 @@ * @signature `list.push(...elements)`

* ```
* var list = new can.List(['Alice']);
* var list = new List(['Alice']);
*

@@ -426,3 +258,3 @@ * list.push('Bob', 'Eve');

* var names = ['Bob', 'Eve'],
* list = new can.List(['Alice']);
* list = new List(['Alice']);
*

@@ -439,8 +271,9 @@ * list.push.apply(list, names);

*
* `push` has a counterpart in [can.List::pop pop], or you may be
* looking for [can.List::unshift unshift] and its counterpart [can.List::shift shift].
* `push` has a counterpart in [can-list.prototype.pop], or you may be
* looking for [can-list.prototype.unshift] and its counterpart [can-list.prototype.shift].
*/
push: "length",
/**
* @function can.List.prototype.unshift unshift
* @function can-list.prototype.unshift unshift
* @parent can-list.prototype
* @description Add elements to the beginning of a List.

@@ -459,3 +292,3 @@ * @signature `list.unshift(...elements)`

* ```
* var list = new can.List(['Alice']);
* var list = new List(['Alice']);
*

@@ -471,3 +304,3 @@ * list.unshift('Bob', 'Eve');

* var names = ['Bob', 'Eve'],
* list = new can.List(['Alice']);
* list = new List(['Alice']);
*

@@ -484,4 +317,4 @@ * list.unshift.apply(list, names);

*
* `unshift` has a counterpart in [can.List::shift shift], or you may be
* looking for [can.List::push push] and its counterpart [can.List::pop pop].
* `unshift` has a counterpart in [can-list.prototype.shift], or you may be
* looking for [can-list.prototype.push] and its counterpart [can-list.prototype.pop].
*/

@@ -523,3 +356,4 @@ unshift: 0

/**
* @function can.List.prototype.pop pop
* @function can-list.prototype.pop pop
* @parent can-list.prototype
* @description Remove an element from the end of a List.

@@ -533,6 +367,6 @@ * @signature `list.pop()`

* @body
* `pop` is the opposite action from `[can.List.push push]`:
* `pop` is the opposite action from [can-list.prototype.push]:
*
* ```
* var list = new can.List(['Alice', 'Bob', 'Eve']);
* var list = new List(['Alice', 'Bob', 'Eve']);
* list.attr(); // ['Alice', 'Bob', 'Eve']

@@ -553,8 +387,9 @@ *

*
* `pop` has its counterpart in [can.List::push push], or you may be
* looking for [can.List::unshift unshift] and its counterpart [can.List::shift shift].
* `pop` has its counterpart in [can-list.prototype.push], or you may be
* looking for [can-list.prototype.unshift] and its counterpart [can-list.prototype.shift].
*/
pop: "length",
/**
* @function can.List.prototype.shift shift
* @function can-list.prototype.shift shift
* @parent can-list.prototype
* @description Remove en element from the front of a list.

@@ -568,6 +403,6 @@ * @signature `list.shift()`

* @body
* `shift` is the opposite action from `[can.List::unshift unshift]`:
* `shift` is the opposite action from `[can-list.prototype.unshift]`:
*
* ```
* var list = new can.List(['Alice']);
* var list = new List(['Alice']);
*

@@ -590,4 +425,4 @@ * list.unshift('Bob', 'Eve');

*
* `shift` has a counterpart in [can.List::unshift unshift], or you may be
* looking for [can.List::push push] and its counterpart [can.List::pop pop].
* `shift` has a counterpart in [can-list.prototype.unshift], or you may be
* looking for [can-list.prototype.push] and its counterpart [can-list.prototype.pop].
*/

@@ -627,3 +462,4 @@ shift: 0

/**
* @function can.List.prototype.indexOf indexOf
* @function can-list.prototype.indexOf indexOf
* @parent can-list.prototype
* @description Look for an item in a List.

@@ -640,3 +476,3 @@ * @signature `list.indexOf(item)`

* ```
* var list = new can.List(['Alice', 'Bob', 'Eve']);
* var list = new List(['Alice', 'Bob', 'Eve']);
* list.indexOf('Alice'); // 0

@@ -665,3 +501,4 @@ * list.indexOf('Charlie'); // -1

/**
* @function can.List.prototype.join join
* @function can-list.prototype.join join
* @parent can-list.prototype
* @description Join a List's elements into a string.

@@ -679,6 +516,6 @@ * @signature `list.join(separator)`

* ```
* var list = new can.List(['Alice', 'Bob', 'Eve']);
* var list = new List(['Alice', 'Bob', 'Eve']);
* list.join(', '); // 'Alice, Bob, Eve'
*
* var beatles = new can.List(['John', 'Paul', 'Ringo', 'George']);
* var beatles = new List(['John', 'Paul', 'Ringo', 'George']);
* beatles.join('&'); // 'John&Paul&Ringo&George'

@@ -693,3 +530,4 @@ * ```

/**
* @function can.List.prototype.reverse reverse
* @function can-list.prototype.reverse reverse
* @parent can-list.prototype
* @description Reverse the order of a List.

@@ -700,7 +538,7 @@ * @signature `list.reverse()`

*
* @return {can.List} the List, for chaining
* @return {can-list} the List, for chaining
*
* @body
* ```
* var list = new can.List(['Alice', 'Bob', 'Eve']);
* var list = new List(['Alice', 'Bob', 'Eve']);
* var reversedList = list.reverse();

@@ -718,3 +556,4 @@ *

/**
* @function can.List.prototype.slice slice
* @function can-list.prototype.slice slice
* @parent can-list.prototype
* @description Make a copy of a part of a List.

@@ -730,7 +569,7 @@ * @signature `list.slice([start[, end]])`

*
* @return {can.List} a new `can.List` with the extracted elements
* @return {can-list} a new `can-list` with the extracted elements
*
* @body
* ```
* var list = new can.List(['Alice', 'Bob', 'Charlie', 'Daniel', 'Eve']);
* var list = new List(['Alice', 'Bob', 'Charlie', 'Daniel', 'Eve']);
* var newList = list.slice(1, 4);

@@ -743,3 +582,3 @@ * newList.attr(); // ['Bob', 'Charlie', 'Daniel']

* ```
* var list = new can.List(['Alice', 'Bob', 'Eve']);
* var list = new List(['Alice', 'Bob', 'Eve']);
* var copy = list.slice();

@@ -759,6 +598,7 @@ *

/**
* @function can.List.prototype.concat concat
* @function can-list.prototype.concat concat
* @parent can-list.prototype
* @description Merge many collections together into a List.
* @signature `list.concat(...args)`
* @param {Array|can.List|*} args Any number of arrays, Lists, or values to add in
* @param {Array|can-list|*} args Any number of arrays, Lists, or values to add in
* For each parameter given, if it is an Array or a List, each of its elements will be added to

@@ -771,7 +611,7 @@ * the end of the concatenated List. Otherwise, the parameter itself will be added.

* ```
* var list = new can.List();
* var list = new List();
* var newList = list.concat(
* 'Alice',
* ['Bob', 'Charlie']),
* new can.List(['Daniel', 'Eve']),
* new List(['Daniel', 'Eve']),
* {f: 'Francis'}

@@ -811,3 +651,4 @@ * );

/**
* @function can.List.prototype.forEach forEach
* @function can-list.prototype.forEach forEach
* @parent can-list.prototype
* @description Call a function for each element of a List.

@@ -825,3 +666,3 @@ * @signature `list.forEach(callback[, thisArg])`

* ```
* var list = new can.List([1, 2, 3]);
* var list = new List([1, 2, 3]);
* list.forEach(function(element, index, list) {

@@ -845,7 +686,8 @@ * list.attr(index, element * element);

/**
* @function can.List.prototype.replace replace
* @function can-list.prototype.replace replace
* @parent can-list.prototype
* @description Replace all the elements of a List.
* @signature `list.replace(collection)`
* @param {Array|can.List|can.Deferred} collection the collection of new elements to use
* If a [can.Deferred] is passed, it must resolve to an `Array` or `can.List`.
* @param {Array|can-list|can.Deferred} collection the collection of new elements to use
* If a [can.Deferred] is passed, it must resolve to an `Array` or `can-list`.
* The elements of the list are not actually removed until the Deferred resolves.

@@ -856,4 +698,4 @@ *

*
* `replace` is especially useful when `can.List`s are live-bound into `[can.Control]`s,
* and you intend to populate them with the results of a `[can.Model]` call:
* `replace` is especially useful when `can-list`s are live-bound into `[can-control]`s,
* and you intend to populate them with the results of a `[can-model]` call:
*

@@ -882,3 +724,3 @@ * ```

* ```
* var attrList = new can.List(['Alexis', 'Bill']);
* var attrList = new List(['Alexis', 'Bill']);
* attrList.bind('change', function(ev, index, how, newVals, oldVals) {

@@ -888,3 +730,3 @@ * console.log(index + ', ' + how + ', ' + newVals + ', ' + oldVals);

*
* var replaceList = new can.List(['Alexis', 'Bill']);
* var replaceList = new List(['Alexis', 'Bill']);
* replaceList.bind('change', function(ev, index, how, newVals, oldVals) {

@@ -1006,12 +848,12 @@ * console.log(index + ', ' + how + ', ' + newVals + ', ' + oldVals);

"can.assignDeep": function(source){
canBatch.start();
queues.batch.start();
// TODO: we should probably just throw an error instead of cleaning
canReflect.assignDeepList(this, source);
canBatch.stop();
queues.batch.stop();
},
"can.updateDeep": function(source){
canBatch.start();
queues.batch.start();
// TODO: we should probably just throw an error instead of cleaning
canReflect.updateDeepList(this, source);
canBatch.stop();
queues.batch.stop();
},

@@ -1018,0 +860,0 @@

{
"name": "can-list",
"version": "4.0.0-pre.2",
"version": "4.0.0-pre.3",
"description": "Observable lists",

@@ -12,5 +12,4 @@ "homepage": "http://canjs.com",

"scripts": {
"preversion": "npm test && npm run build",
"version": "git commit -am \"Update dist for release\" && git checkout -b release && git add -f dist/",
"postversion": "git push --tags && git checkout master && git branch -D release && git push",
"preversion": "npm test",
"postpublish": "git push --tags && git push",
"testee": "testee test/test.html --browsers firefox",

@@ -23,3 +22,2 @@ "test": "npm run detect-cycle && npm run jshint && npm run testee",

"release:major": "npm version major && npm publish",
"build": "node build.js",
"detect-cycle": "detect-cyclic-packages --ignore done-serve"

@@ -40,13 +38,17 @@ },

"dependencies": {
"can-cid": "^1.0.0",
"can-construct": "^3.2.0",
"can-event": "^3.6.0",
"can-map": "^4.0.0-pre.0",
"can-namespace": "1.0.0",
"can-observation": "^4.0.0-pre.18",
"can-queues": "^0.2.8",
"can-cid": "^1.1.2",
"can-construct": "^3.2.1",
"can-event-queue": "<2.0.0",
"can-namespace": "^1.0.0",
"can-observation-recorder": "<2.0.0",
"can-observation": "^4.0.0-pre.19",
"can-reflect": "^1.7.2",
"can-simple-observable": "^2.0.0-pre.16",
"can-stache-key": "^1.0.0-pre.9",
"can-symbol": "^1.4.1",
"can-types": "^1.1.1",
"can-util": "^3.10.12"
"can-types": "^1.1.0",
"can-util": "^3.10.12",
"can-compute": "^4.0.0-pre.1",
"can-queues": "<2.0.0",
"can-map": "^4.0.0-pre.0"
},

@@ -53,0 +55,0 @@ "devDependencies": {

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