
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
npm install myao
//or
npm install --save myao
var myao = require('myao'),
arrayofobj = [
{name: 'Johnny', team: 'Black', age:28, id: '001'},
{name: 'Simon', team: 'Red', age:32, id: '002'},
{name: 'Leonardo', team: 'Blue', age: 18, id: '003'},
{name: 'Don', team: 'White', age:40, id: '004'}
];
var myaoObj = myao.create(arrayofobj);
myaoObj.getAll()
return - array
myaoObj.getAll();
/* return
[
{ name: 'Johnny', team: 'Black', age:28, id: '001'},
{ name: 'Simon', team: 'Red', age:32, id: '002'},
{ name: 'Leonardo', team: 'Blue', age: 18, id: '003'},
{ name: 'Don', team: 'White', age:40, id: '004'}
]
*/
myaoObj.add(toAdd, toTheBeginning)
toAdd - single object or array of objects
toTheBeginning >= 1.3.2 - boolean - true for 'add' to the beginning of data;
return - this
myaoObj.add({name: 'Bill', team: 'Blue', age:26, id: '005'});
myaoObj.add([{name: 'Bill', team: 'Black', age:23, id: '006'}, {name: 'Sue', team: 'White', age:20, id: '007'}]);
/* myaoObj.getAll() return:
[
{ name: 'Johnny', team: 'Black', age:28, id: '001'},
{ name: 'Simon', team: 'Red', age:32, id: '002'},
{ name: 'Leonardo', team: 'Blue', age: 18, id: '003'},
{ name: 'Don', team: 'White', age:40, id: '004'},
{ name: 'Bill', team: 'Blue', age: 26, id: '005' },
{ name: 'Bill', team: 'Black', age: 23, id: '006' },
{ name: 'Sue', team: 'White', age: 20, id: '007' }
]
*/
myaoObj.add({name: 'Peggy', team: 'Pink', age:21, id: '008'}, true);
/* myaoObj.getAll() return:
[
{name: 'Peggy', team: 'Pink', age:21, id: '008'},
{ name: 'Johnny', team: 'Black', age:28, id: '001'},
{ name: 'Simon', team: 'Red', age:32, id: '002'},
{ name: 'Leonardo', team: 'Blue', age: 18, id: '003'},
{ name: 'Don', team: 'White', age:40, id: '004'},
{ name: 'Bill', team: 'Blue', age: 26, id: '005' },
{ name: 'Bill', team: 'Black', age: 23, id: '006' },
{ name: 'Sue', team: 'White', age: 20, id: '007' }
]
*/
myaoObj.get(key, id)
key - string - object key
id - unique value
return - first matching object or null
var blackbill = myaoObj.get('id', '006' )
blackbill.team //'Black'
//!!BUT!!
var blackbill = myaoObj.get('name', 'Bill' );
blackbill.team //'Blue'
!! This method return object reference so:
var blackbill = myaoObj.get('id', '006' );
blackbill.hobby = 'country music';
/* myaoObj.getAll() return:
[
{ name: 'Johnny', team: 'Black', age:28, id: '001'},
{ name: 'Simon', team: 'Red', age:32, id: '002'},
{ name: 'Leonardo', team: 'Blue', age: 18, id: '003'},
{ name: 'Don', team: 'White', age:40, id: '004'},
{ name: 'Bill', team: 'Blue', age: 26, id: '005' },
{ name: 'Bill', team: 'Black', age: 23, id: '006', hobby: 'country music' },
{ name: 'Sue', team: 'White', age: 20, id: '007' }
]
*/
myaoObj.set(key, id, obj)
key - string - object key
id - unique value
obj - object with propertys to assign
return - this
var bluebill = myaoObj.get('id', '005' );
myaoObj.set('id', '005', {job: 'Programmer'});
console.log(bluebill)
//{ name: 'Bill', team: 'Blue', age: 26, id: '005', job: 'Programmer' }
myaoObj.remove(key, id)
key - string - object key
id - unique value
return - this
!! It removes FIRST matching object - to remove a group of objects use filter method
myaoObj.remove('id', '006');
/* myaoObj.getAll() return
[
{ name: 'Johnny', team: 'Black', age: 28, id: '001' },
{ name: 'Simon', team: 'Red', age: 32, id: '002' },
{ name: 'Leonardo', team: 'Blue', age: 18, id: '003' },
{ name: 'Don', team: 'White', age: 40, id: '004' },
{ name: 'Bill', team: 'Blue', age: 26, id: '005' },
{ name: 'Sue', team: 'White', age: 20, id: '007' } ]
*/
myaoObj.replace(key, id, obj)
key - string - object key
id - unique value
obj - object with propertys to assign
return - this
var bluebill = myaoObj.get('id', '005' );
myaoObj.replace('id', '005', {name: 'Anonymous'});
console.log(bluebill);
//{ name: 'Anonymous'}
/* myaoObj.getAll() return
[
{ name: 'Johnny', team: 'Black', age: 28, id: '001' },
{ name: 'Simon', team: 'Red', age: 32, id: '002' },
{ name: 'Leonardo', team: 'Blue', age: 18, id: '003' },
{ name: 'Don', team: 'White', age: 40, id: '004' },
{ name: 'Anonymous' },
{ name: 'Sue', team: 'White', age: 20, id: '007' } ]
*/
myaoObj.overwrite(newData);
newData - array
return - this
myaoObj.overwrite([{name: "Peter", team:"Green"}]);
/* myaoObj.getAll() return
[{name: "Peter", team:"Green"}]
*/
myaoObj.filter(key, val);
key - string - object key ; 'use '-' for revers filter
val - single filter value or array of values
return - new myao object with filtered data
var bluered = myaoObj.filter('team', ['Blue', 'Red']);
var notblue = myaoObj.filter('-team', 'Blue');
/* bluered.getAll() return
[ { name: 'Simon', team: 'Red', age: 32, id: '002' },
{ name: 'Leonardo', team: 'Blue', age: 18, id: '003' },
{ name: 'Bill', team: 'Blue', age: 26, id: '005' } ]
*/
/* notblue.getAll() return
[ { name: 'Johnny', team: 'Black', age: 28, id: '001' },
{ name: 'Simon', team: 'Red', age: 32, id: '002' },
{ name: 'Don', team: 'White', age: 40, id: '004' },
{ name: 'Sue', team: 'White', age: 20, id: '007' } ]
*/
myaoObj.sort(key);
key - string - object key ; 'use '-' for revers sort
return - this
myaoObj.sort('age');
/* myaoObj.getAll() return
[ { name: 'Leonardo', team: 'Blue', age: 18, id: '003' },
{ name: 'Sue', team: 'White', age: 20, id: '007' },
{ name: 'Bill', team: 'Blue', age: 26, id: '005' },
{ name: 'Johnny', team: 'Black', age: 28, id: '001' },
{ name: 'Simon', team: 'Red', age: 32, id: '002' },
{ name: 'Don', team: 'White', age: 40, id: '004' } ]
*/
//!!BUT!!
myaoObj.sort('-age');
/*myaoObj.getAll() return
[ { name: 'Don', team: 'White', age: 40, id: '004' },
{ name: 'Simon', team: 'Red', age: 32, id: '002' },
{ name: 'Johnny', team: 'Black', age: 28, id: '001' },
{ name: 'Bill', team: 'Blue', age: 26, id: '005' },
{ name: 'Sue', team: 'White', age: 20, id: '007' },
{ name: 'Leonardo', team: 'Blue', age: 18, id: '003' } ]
*/
myaoObj.each(callback)
callback - function with two parameters; first it is object in array, and second is index
myaoObj.each (function (elem, index) {
elem.nick = elem.name.substr(0,2) + index;
});
/* myObj.getAll() return
[ { name: 'Johnny', team: 'Black', age: 28, id: '001', nick: 'Jo0' },
{ name: 'Simon', team: 'Red', age: 32, id: '002', nick: 'Si1' },
{ name: 'Leonardo', team: 'Blue', age: 18, id: '003', nick: 'Le2' },
{ name: 'Don', team: 'White', age: 40, id: '004', nick: 'Do3' },
{ name: 'Bill', team: 'Blue', age: 26, id: '005', nick: 'Bi4' },
{ name: 'Sue', team: 'White', age: 20, id: '007', nick: 'Su5' } ]
*/
myaoObj.getValues(key)
key - string - object key ; 'use '-' for revers sort
return - array with values
var names = myaoObj.getValues('name');
console.log(names); //[ 'Johnny', 'Simon', 'Leonardo', 'Don', 'Bill', 'Sue' ]
myaoObj.getLength()
return - number - data length
var myaolength = myaoObj.getLength();
console.log(myaolength); // 6
FAQs
Manage Your Array of Objects
The npm package myao receives a total of 0 weekly downloads. As such, myao popularity was classified as not popular.
We found that myao 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.