
Security News
/Research
Popular node-ipc npm Package Infected with Credential Stealer
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.
A global registry to handle configs and flags
Developers always declared placed the constants, flags and application configs in different files. Here we provide a global registry to handle them. Global variable is not an evil, in case you know what you are doing.
Semantic key
The key name of object literals in JavaScript is case sensitive. In this module, all key names in registry is case insensitive because intuitively it maintains the same semantic meaning.
Predictable mutability
Developers now clearly knows whether the global variables are immutable at the very beginning.
$ npm install robjectory
var robjectory = require('robjectory');
robjectory.register (key, value, options)
key is a string representing the name of key.
value is optional indicating the value of the key. Default is the name of key.
options is an optional object for advanced configuration.
options.ignoreCapital is a boolean indicating the format of key, the written style of constants and global variables commonly uses UPPERCASE. Default is false.options.isMutable is a boolean indicating the mutability of the key-value pair. Once the key is registered, the corresponding value cannot be modified if this boolean is set to false. Default is false.options.isDual is a boolean indicating the duality of the key-value pair. It can be used to search the key by value and vice versa. The dual will follow the same mutability and name convention.robjectory.register('flag');
// true
robjectory.register('FlAg');
// false
robjectory.register('constant', 123);
// true
robjectory.register('newFlag',{
ignoreCapital: true
});
// true
// the key is 'newFlag', just follow the input
robjectory.mutate (key, value)
It returns true after mutation. Return false if the value is immutable.
robjectory.mutate is the only method that can mutate the value in the registered key-value pair. Mutable variables makes the application unpredictable. Let's imagine if the global configuration setting is changed in some file and cause conflict, it's hard to point out where it changes the value. That's why all key-value pair here is unique and immutable by default once the key is registered.
If developers still want to use mutable variables, it's allowed in our module, but they do need to set the option manually so they acknowledge such variable/config is mutable.
robjectory.register('mutable','initialValue',{
isMutable: true
});
// true { MUTABLE: 'initialValue' }
robjectory.mutate ('mutable','newValue');
// true { MUTABLE: 'newValue' }
robjectory.isMutable (key)
Check whether the value in a registered key-value pair is mutable.
robjectory.register('mutable','initialValue',{
isMutable: true
});
robjectory.isMutable ('mutable');
// true
robjectory.hasKey (key)
Check whether the key is registered.
robjectory.register('hasKeyTest');
robjectory.hasKey('hasKeyTest');
// true
robjectory.remove (key)
It returns true if the key-value pair is successfully removed. Returns false indicating the non-exist key.
robjectory.register('flag');
// the corresponding value is 'flag'
robjectory.remove('flag');
// true
robjectory.remove('flag');
// false because the key-value pair is deleted in the last step
robjectory.getValue (key)
It returns the corresponding value. If the key is not registered, it returns undefined.
robjectory.getValue('no-flag');
// undefined
robjectory.register('flag');
robjectory.getValue('flag');
// 'flag'
robjectory.findKeyName (key)
It returns the actual name of key used in object.
robjectory.register('flag');
robjectory.findKeyName('flag');
// FLAG
robjectory.findKeyName('flAg');
// FLAG
robjectory.register('tHiSiSmYkEy','value',{
ignoreCapital: true
});
robjectory.findKeyName('thisismykey');
// tHiSiSmYkEy
Copyright (C) 2015 Tony Ngan, released under the MIT License.
FAQs
A global registry to handle configs and flags
We found that robjectory 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
/Research
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.

Security News
TeamPCP and BreachForums are promoting a Shai-Hulud supply chain attack contest with a $1,000 prize for the biggest package compromise.

Security News
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.