
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
level2-base
Advanced tools
Provides the base class and other bits of code that were being re-used within level2 projects.
The Class
class provides a simple way of defining new classes and extending classes.
All uses of Class
must extend Class
itself or one of its subclasses.
var Something = Class.extend({
// Provide prototype here
});
var ChildSomething = Something.extend({
// Override Something prototoype if needed
});
:information_source: Within override methods a special function, this._super
, is available
to call the super class's function (note that this is only defined in the child function
and is removed after the method returns)
To provide a constructor use the init
property of the prototype.
This function will be called when an instance is constructed.
var Something = Class.extend({
init: function() {
// Do initialization here
}
});
Mixins are also supported when using Class.extend()
.
var Something = Class.extend(Mixin1, Mixin2, {
// Provide prototype here
});
Function
Extends a Class
with a new prototype.
If any mixins are provided their attributes will be copied to the new class's prototype.
Function
: mixins to apply to this classObject
: prototype to apply to this classFunction
Extends any type, even if that type was not created from Class.extend()
.
Function
: the base type to extendFunction
: mixins to apply to the extended classObject
: prototype to apply to the extended classBuilt in extension of the javascript Error
class which includes an extend()
method.
Really this is just a convenience to calling Class.extendGeneric(Error)
.
Constructs a new error message
String
: The error's message:warning: The stack will be traced up to the line where the error was constructed, not where it is thrown. (throwing errors in the same line they are constructed minimizes this issue).
Because it was used so often a simple event emitter class is provided. This is intended to be used as a mixin.
Adds an event listener for the given event name.
String
: The event name that the listener is waiting forFunction
: The event handler functionCalls all the registered event listeners for the given event.
String
: The event to fireMixed
: The arguments to pass to the event handlersProvides an interface to cache persistent data to a data file. To create a new settings file simply instantiate a Settings instance and pass the path to the file you want to create.
var newSettings = new Settings('/path/to/settings-file.json');
newSettings.set('someKey', 'someValue');
:warning: The settings file won't be created until Settings.set()
is
called for the first time;
To retrieve settings values use the Settings.get()
method.
var sett = new Settings('/path/to/settings-file.json');
sett.get('some.value').then(function(someValue) {
console.log(someValue);
});
Note that keys containing dots ('.'
) will enter into objects.
If the base object does not exists undefined
will be returned as
the settings value.
Creates a new Settings instance backed by the settings file
String
: The path to this settings storage filePersistenceInterface
: The optional interface used for
serializing and de-serializing the settings data (defaults to the provided
JSONInterface
)Promise - Object
Get the data at the key
String
: The key for the data to get:arrow_right: Returns a promise for the setting value
Promise
Sets the data at the given key
String
: Key of the setting to setAny
: The data to store (must
be JSON serializable):arrow_right: Returns a promise that resolves when data is stored
String
Get the file path used during initialization
:arrow_right: Returns the settings path
A PersistenceInterface
implementation provides a way to serialize and
de-serialize data in a generic fashion.
Originally this was added for use with the Settings
class.
String
Returns the string representation of the data
Object
: The data to serialize:arrow_right: Returns the serialized data
Object
Returns the parsed data
String
: The data to be parsed:arrow_right: Returns the parsed data
An implementation of PersistenceInterface
using the JSON specification.
Create an interface using optional options
Object
: Objects for the interface
String
: The indent to use when serializing (default ' '
, 4 spaces)FAQs
Level2 Base Module
The npm package level2-base receives a total of 0 weekly downloads. As such, level2-base popularity was classified as not popular.
We found that level2-base 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
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.