Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Observable Objects
can-map
Create observable objects.
new Map([props])
Creates a new instance of can.Map.
{Object}
:
Properties and values to seed the Observe with.{can.Map}
:
An instance of can.Map
with the properties from props.Map.extend([name,] [staticProperties,] instanceProperties)
Creates a new extended constructor function.
map.attr()
Gets a collection of all the properties in this Map
.
{Object}
:
an object with all the properties in this Map
.map.attr(key)
Reads a property from this Map
.
{String}
:
the property to read{*}
:
the value assigned to key.map.attr(key, value)
Assigns value to a property on this Map
called key.
{String}
:
the property to set{*}
:
value to assign to key.{can.Map}
:
this Map, for chainingmap.attr(obj[, removeOthers])
Assigns each value in obj to a property on this Map
named after the
corresponding key in obj, effectively merging obj into the Map.
obj {Object}
:
a collection of key-value pairs to set.
If any properties already exist on the Map
, they will be overwritten.
removeOthers {bool}
:
whether to remove keys not present in obj.
To remove keys without setting other keys, use [can.Map::removeAttr removeAttr]
.
{can.Map}
:
this Map, for chainingmap.bind(eventType, handler)
{String}
:
the type of event to bind this handler to{function}
:
the handler to be called when this type of event fires
The signature of the handler depends on the type of event being bound. See below
for details.{can.Map}
:
this Map, for chainingmap.compute(attrName)
{String}
:
the property to bind to{can-compute}
:
a [can-compute] bound to attrName{*}
Specify a default property and value.
*
A value of any type other than a function that will
be set as the DEFAULT-ATTR
attribute's value.
map.each( callback(item, propName ) )
each
iterates through the Map, calling a function
for each property value and key.
{function(item, propName)}
:
the function to call for each property
The value and key of each property will be passed as the first and second
arguments, respectively, to the callback. If the callback returns false,
the loop will stop.{can-map}
:
this Map, for chainingmap.removeAttr(attrName)
{String}
:
the name of the property to remove{*}
:
the value of the property that was removedmap.serialize()
Get the serialized Object form of the map. Serialized data is typically used to send back to a server.
o.serialize() //-> { name: 'Justin' }
Serialize currently returns the same data as [can.Map.prototype.attrs]. However, in future versions, serialize will be able to return serialized data similar to [can.Model]. The following will work:
new Map({time: new Date()})
.serialize() //-> { time: 1319666613663 }
{Object}
:
a JavaScript Object that can be
serialized with JSON.stringify
or other methods.map.unbind(eventType[, handler])
{String}
:
the type of event to unbind, exactly as passed to bind
{function}
:
the handler to unbindvar map = new Map({ a: 1 });
function log(){
console.log("val", map.attr("a");
}
map.bind("change", log);
map.attr("a", 2);
// Bind callback called.
map.unbind("change", log);
Map.keys(map)
var people = new Map({
a: 'Alice',
b: 'Bob',
e: 'Eve'
});
Map.keys(people); // ['a', 'b', 'e']
{can-map}
:
the Map
to get the keys from{Array}
:
array An array containing the keys from map.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 Objects
The npm package can-map receives a total of 1,310 weekly downloads. As such, can-map popularity was classified as popular.
We found that can-map demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 15 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.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
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.