Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
basic-collection
Advanced tools
A generic collection class to contain array-like data.
$ npm install basic-collection
import BasicCollection from "basic-collection";
let Collection = new BasicCollection;
Collection.set( "key_1", "value_1" );
Collection.set( "key_2", "value_2" );
Collection.set( 1234567, true );
Collection.get( "key_1" ); // value_1
Collection.get( "key_2" ); // value_2
Collection.get( "key_3", "default" ); // default
Collection.has( "key_1" ); // true
Collection.has( "key_2" ); // true
Collection.has( "key_3" ); // false
Collection.remove( "key_2" );
console.log( Collection.size ); // 2
console.log( Collection.keys ); // [ 'key_1', 1234567 ]
console.log( Collection.values ); // [ 'value_1', true ]
console.log( Collection.entries ); // [ [ 'key_1', 'value_1' ], [ '1234567', 'true' ] ]
Collection.each( ( key, value, map ) => {
console.log( `Collection[${key}] = ${value}` );
} );
Collection.clear();
console.log( Collection.size ); // 0
import BasicCollection from "basic-collection";
class MyCollection {
constructor( parameters ) {
super( parameters );
}
normalize( key ) {
return `transformed_${key}`;
}
}
let Collection = new MyCollection;
Collection.set( "key_1", "value_1" );
Collection.set( "key_2", "value_2" );
console.log( Collection.keys );
// => [ 'transformed_key_1', "transformed_key_2" ]
Method | Access | Return |
---|---|---|
normalize( key ) | protected | string |
set( key, value ) | public | null |
get( key[, default] ) | public | mixed |
has( key ) | public | bool |
remove( key ) | public | null |
clear() | public | null |
each( callback ) | public | null |
size | public | int |
entries | public | iterable |
keys | public | iterable |
values | public | iterable |
FAQs
A generic collection class to contain array-like data
The npm package basic-collection receives a total of 1 weekly downloads. As such, basic-collection popularity was classified as not popular.
We found that basic-collection demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.