Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
achieve modularity and separation of concerns through feature-oriented development
achieve modularity and separation of concerns through feature-oriented programming
Programming is an activity very prone to human error, especially if you have multiple developers changing the same code-base at the same time. As more and more features are implemented by different programmers, progress will often slow to a crawl. Programmers can easily lose overview and step on each others toes when their code is spread across the code base surrounded by the code of others.
delta.js helps you organize your JavaScript code in terms of features. As it turns out, files, modules, objects, functions (and so on), are not the right abstractions for describing a feature. But they are very good at other stuff! This library introduces the notion of a delta, which complements those other constructs.
A delta is the place to gather all the code belonging to a specific feature. Basically, for each piece of code, you instruct the delta to put that code in the file, module, object or function where it belongs. That way, the code can physically be gathered in one place, and therefore be easy to maintain.
This has other benefits as well. By having some deltas be explicitly applied after others, you give them permission to overwrite things. If two deltas that are unordered try to overwrite each others code, you will get a friendly error message. Moreover, by separating your features so explicitly, you will be able to turn them on or off with a switch, for either debugging or production.
This might all seem overly complicated at first. But once you get started, you'll soon fall in love with this approach.
At this time, delta.js is a runtime library. But in concept, deltas could be applied by a preprocessor. This will be supported by a future version.
This library depends only on the Babel ES6 polyfill. For your convenience, a delta.js version is provided with this polyfill already baked in, but you also have the option of providing it yourself.
delta.js
is available as a Bower package:
bower install delta.js
Unfortunately, the Babel polyfill is not distributed through Bower. So you'll have to either use the version of delta.js with the polyfill baked in, or you'll have to get the polyfill from someplace else, like NPM.
delta.js
is available as an NPM package:
npm install delta.js
DeltaJs
The delta.js package offers a UMD API, so it supports AMD (RequireJS), CommonJS and script-tags:
requirejs(['lib/delta.js/dist/delta.js'], function (DeltaJs) {
// use DeltaJs
});
var DeltaJs = require('lib/delta.js/dist/delta.js')
// use DeltaJs
<script src="lib/delta.js/dist/delta.js"></script>
<!-- use DeltaJs -->
###Files
The dist
directory offers different files for use in different circumstances.
Use the following table to determine which file to use in your situation.
File | Description |
---|---|
delta.js ,delta.min.js | requires you to load the Babel polyfill yourself |
delta.full.js ,delta.full.min.js | already includes the Babel polyfill |
If you don't know which you need, you probably want delta.full.min.js
, because it will work out-of-the-box. But it is generally more elegant to load the polyfill yourself, especially if you use other libraries that depend on it.
DeltaJs#Feature
*
DeltaJs#Proxy
This class offers every functionality you need from delta modeling. Each instance offers its own operation types and variation points and acts as a facade (as in design pattern) to the more specific subsystems of delta.js.
Using multiple DeltaJs
instances allows you to use different sets
of deltas and rules in the same project that work independently
from each other. But you will usually need only one DeltaJs
instance per application.
DeltaJs#Proxy
{@public}{@method}
Using multiple DeltaJs
instances allows you to use different sets
of deltas and rules in the same project that work independently
from each other. But you will usually need only one DeltaJs
instance per application.
Param | Type | Description |
---|---|---|
method | string | method name |
handler | function | a function that takes method arguments, and returns a new DeltaJs#Delta instance |
DeltaJs#Feature
Param | Type | Description |
---|---|---|
name | string | the name of the new feature |
options | object | the (optional) options for the new feature |
Returns: DeltaJs#Feature
- - the object representing the new feature
This method allows you to tell delta.js about a new kind of delta operation.
This was also done for existing operations like modify
, add
, remove
, and so on.
Param | Type | Description |
---|---|---|
name | string | name of the new operation type |
DeltaSubclass | function | the new operation class |
ProxySubclass | function | the optional custom Proxy subclass for this operation-type |
*
This method indicates a variation point.
Param | Type | Description |
---|---|---|
name | string | a hook by which operations from the core delta model can be applied |
val | * | the initial value of this variation point |
Returns: *
- - the value of this variation point after applying the appropriate deltas
DeltaJs#Proxy
A {DeltaJs} instance has one fundamental {DeltaJs#DeltaModel} instance, which is applied to any variation points that are encountered. This method is an alias to the eponymous method on that 'root' delta model. It returns the proxy that allows new delta operations to be added more easily. It presets the 'feature' option to 'true', but this can be overwritten manually.
Returns: DeltaJs#Proxy
- - the proxy to this delta, for easily adding operations
DeltaJs#Proxy
{@public}{@method}
Param | Type |
---|---|
args | Array.<*> |
delta.js
is released under the terms of the MIT license.
It permits reuse within both open and proprietary software, provided
all copies of the licensed software include a copy of the MIT License
terms and the copyright notice.
Here is an incomplete list of future plans for this library:
FAQs
achieve modularity and separation of concerns through feature-oriented development
We found that delta.js 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
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.