
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.
The most simple, customizable and easy to use JavaScript standard inheritance library
The most simple, customizable and easy to use JavaScript standard inheritance library.
@ Inspired by Douglass Crockford’s website :(http://javascript.crockford.com/prototypal.html).
@ Inspired by Cyril Agosta’s library : (https://github.com/cagosta/SeedHq).
@ Inspired by Angular Framework : (https://github.com/angular/angular.js).
@ Inspired by JQuery extend's function : (https://github.com/jquery/jquery).
npm install embryo
<script src="dist/embryo-0.1.6.min.js" type="text/javascript"></script>
var Embryo = require('embryo')
var Human = Embryo.extend({
'_type': 'Human', // define class internal type
properties : { // define all class properties
name: 'John',
score: 1000,
power: 2,
options: [
'super',
]
},
init: function() { // define class constructor
this.lifes = 3
},
walk: function() {
console.log('walk', this.power)
},
run: function() { // define a simple method
console.log('0 arg')
},
'run|1': function( arg1 ) { // define a surcharged method
console.log('1 arg') // when you call run( 'foo' )
},
'run|2': function( arg1, arg2 ) { // define a surcharged method
console.log('2 args') // when you call run( 'foo', 'bar' )
},
'run|3': function( arg1, arg2, arg3 ) {
console.log('3 args')
},
'$isDead': function (life) { // prefix your method name with $ to make it static
return life < 1
}
})
Human.isDead(2) // static method return false
var Superman = Human.extend({
'_type': 'Superman',
'_blacklist': [
'Attribute', // Attribute plugin blacklisted for this class
'*' // All plugins are blacklisted for this class
],
properties : {
name: 'Clark Kent',
score: 5000,
power: 10,
options: [
'super',
'godness',
'unlimited'
]
},
init: function() {
this.lifes = 10
},
'-walk': function() { // called before 'walk' call
console.log('before walk')
},
'+walk': function() { // called after 'walk' call
console.log('after walk')
},
fly: function() {
console.log('fly', this.power)
}
})
var human = new Human()
human.walk() // -> walk: 2
console.log( human.getScore() ) // -> 1000
console.log( human.getName() ) // -> John
console.log( human.getOptions() ) // -> ['super']
human.run() // -> call method run()
human.run( '1' ) // -> call method human['run|1']()
human.run( '1', '2' ) // -> call method human['run|2']()
human.run( '1', '2', '3' ) // -> call method human['run|3']()
human.run( '1', '2', '3', '4' ) // -> call default method run()
var superman = new Superman()
superman.walk() // -> before walk
// -> walk: 10
// -> after walk
superman.fly() // -> fly: 10
superman.getFly() // Error, Attribute plugin blacklisted,
// there is no generated method with name 'getFly'
console.log( human instanceof Human ) // -> true
console.log( human instanceof Superman ) // -> false
console.log( superman instanceof Human ) // -> true
To configure Embryo
:
Embryo.configure({
cstrName: 'init', // default class constructor name
cstrArrayName: '_types', // default constructors array name
forceCstr: true, // class constructor required ?
nameType: '_type', // default class type property name
typeDefault: 'Embryo', // default class type value
forceTyping: true, // add a default class type if not exists
nameProperties: 'properties', // default property object name
nameBlacklist: '_blacklist', // array key witch contains disabled plugins names
deleteBlacklist: true // delete blacklist array before class instanciation ?
})
Embryo enables by default 4 plugins :
Embryo.plugins('Attribute').configure({
getPrefix: 'get', // default get prefix name
setPrefix: 'set', // default set prefix name
camelize: true // camelize generated methods names (getscore or getScore)
})
Embryo.plugins('BeforeAfter').configure({
beforePrefix: '-', // default before trigger prefix in method name (ex: -score)
afterPrefix: '+', // default after trigger prefix in method name (ex: +score)
hiddenPrefix: '_bah_' // default prefix for hidden method (ex: score() -> call _bah_score())
})
Embryo.plugins('Surcharge').configure({
suffix: '|', // default trigger suffix in method name (ex: score|2)
hiddenPrefix: '_pm_' // default prefix for hidden method (ex: score() -> call _pm_score())
})
Embryo.plugins('Static').configure({
prefix: '$' // default prefix name
})
var MyPlugin = Embryo.Plugin.extend({
name: 'MyPlugin', // your plugin's name
options: {
option1: 'value1', // your plugin's options...
option2: 'value2',
option3: 'value3'
},
init: function() { // your plugin's constructor
},
//
// Embryo execute this function for all class creation
// o: class properties
// debug: debug mode for this plugin
// child: class's prototype
//
exec: function( o, debug, child ) {
// Check if your plugin is blacklisted for this class
if (this.isBlacklisted( o )) {
debug && console.log( '[' + this.name + '] - SKIPPED' )
return o
}
// if debug mode is enabled for this plugin,
// show all class property before class creation
debug && debug( this.name, 'BEFORE', o )
// your plugin's code...
// if debug mode is enabled for this plugin,
// show all class property after class creation
debug && debug( this.name, 'AFTER', o )
// return new class properties
return o
}
})
// Create an instance of your plugin
var myPlugin = new MyPlugin()
// Tell embryo to use your new plugin
// use( plugin, debug )
Embryo.use( myPlugin, false )
// Now, you will able to reconfigure your plugin later...
Embryo.plugins('MyPlugin').configure({
option1: 'value1', // your plugin's options...
option2: 'value2',
option3: 'value3'
})
:heart: Donations are always welcome :heart:.
Coins | Symbols | Addresses |
---|---|---|
BTC | 3B52fbzNFQTaKZxWf5GrCUsASD2UP8na4A | |
ETH | 0x1C389f1f85Cdb3C2996b83fAc87E496A80698B7C |
FAQs
The most simple, customizable and easy to use JavaScript standard inheritance library
The npm package embryo receives a total of 4 weekly downloads. As such, embryo popularity was classified as not popular.
We found that embryo 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.