Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
can-list
new List([array])
new List(deferred)
List.extend([name,] [staticProperties,] instanceProperties)
Map can-map
list.attr()
list.attr(index)
list.attr(index, value)
list.attr(elements[, replaceCompletely])
list.filter(filterFunc, context)
list.splice(index[, howMany[, ...newElements]])
list.each( callback(item, index) )
list.reverse()
list.map( callback(item, index, listReference), context )
can-list
new List([array])
Create an observable array-like object.
{Array}
:
Items to seed the List with.{can-list}
:
An instance of List
with the elements from array.new List(deferred)
{can.Deferred}
:
A deferred that resolves to an
array. When the deferred resolves, its values will be added to the list.returns {can-list}
:
An initially empty List
.
List.extend([name,] [staticProperties,] instanceProperties)
Creates a new extended constructor function. Learn more at [can.Construct.extend].
var MyList = List.extend({}, {
// silly unnecessary method
count: function(){
return this.attr('length');
}
});
var list = new MyList([{}, {}]);
console.log(list.count()); // -> 2
name {String}
:
If provided, adds the extened List constructor function to the window at the given name.
staticProperties {Object}
:
Properties and methods directly on the constructor function. The most common property to set is Map.
instanceProperties {Object}
:
Properties and methods on instances of this list type.
{can-map}
Specify the Map type used to make objects added to this list observable.
can-map
When objects are added to a List
, those objects are converted into can.Map instances. For example:
var list = new List();
list.push({name: "Justin"});
var map = list.attr(0);
map.attr("name") //-> "Justin"
By changing Map, you can specify a different type of Map instance to create. For example:
var User = Map.extend({
fullName: function(){
return this.attr("first")+" "+this.attr("last")
}
});
User.List = List.extend({
Map: User
}, {});
var list = new User.List();
list.push({first: "Justin", last: "Meyer"});
var user = list.attr(0);
user.fullName() //-> "Justin Meyer"
list.attr()
Gets an array of all the elements in this List
.
{Array}
:
An array with all the elements in this List.list.attr(index)
Reads an element from this List
.
{Number}
:
The element to read.{*}
:
The value at index.list.attr(index, value)
Assigns value to the index index on this List
, expanding the list if necessary.
{Number}
:
The element to set.{*}
:
The value to assign at index.{}
:
This list, for chaining.list.attr(elements[, replaceCompletely])
Merges the members of elements into this List, replacing each from the beginning in order. If elements is longer than the current List, the current List will be expanded. If elements is shorter than the current List, the extra existing members are not affected (unless replaceCompletely is true
). To remove elements without replacing them, use [can-map::removeAttr removeAttr]
.
elements {Array}
:
An array of elements to merge in.
replaceCompletely {bool}
:
whether to completely replace the elements of List
If replaceCompletely is true
and elements is shorter than the List, the existing extra members of the List will be removed.
{}
:
This list, for chaining.list.filter(filterFunc, context)
{function(item, index, undefined)}
:
A function to call with each element of the list. Returning false
will remove the index.{Object}
:
The object to use as this
inside the callback.list.splice(index[, howMany[, ...newElements]])
index {Number}
:
where to start removing or inserting elements
howMany {Number}
:
the number of elements to remove
If howMany is not provided, splice
will remove all elements from index
to the end of the List.
newElements {*}
:
elements to insert into the List
{Array}
:
the elements removed by splice
list.each( callback(item, index) )
each
iterates through the List, calling a function
for each element.
var list = new List([1, 2, 3]);
list.each(function(elem){
console.log(elem);
});
{function(*, Number)}
:
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.{}
:
this List, for chaininglist.reverse()
reverse
reverses the elements of the List in place.
{can-list}
:
the List, for chaininglist.map( callback(item, index, listReference), context )
{function(*, Number, undefined)}
:
A function to call with each
element of the list.{Object}
:
An optional object to use as this
inside the callback.{}
:
A new can.List instance.To make a build of the distributables into dist/
in the cloned repository run
npm install
node build
Tests can run in the browser by opening a webserver and visiting the test.html
page.
Automated tests that run the tests from the command line in Firefox can be run with
npm test
FAQs
Observable lists
The npm package can-list receives a total of 792 weekly downloads. As such, can-list popularity was classified as not popular.
We found that can-list demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 11 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.