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.
immutable-angular
Advanced tools
Support for watching and enumerating immutable-js collections in Angular 1.x
Install immutable-angular
using npm or jspm
npm install immutable-angular
jspm install npm:immutable-angular
Include the 'immutable'
module as a dependency of your module
import 'immutable-angular';
angular.module('myModule', ['immutable-angular']);
Iterate over and watch Immutable structures
import Immutable from 'immutable';
class SomethingController {
static get $inject() { return ['$scope']; }
constructor($scope) {
this.list = Immutable.List([1, 2, 3]);
$scope.$watchImmutable(() => this.list, () => this.listChanged());
}
listChanged() {
// ...
}
}
<ul>
<li repeat-immutable="item in something.list">{{item}}</li>
</ul>
$watchImmutable(watchExpression: function | string, listener: function)
$watchImmutable
allows for the watching of Immutable data structures with
dirty checking based on the Immutable.is()
function. It will compile
watchExpression
to a getter and then delegate to the original $watch()
using a wrapper getter which only returns a new result if Immutable.is()
reports a change in the value.
repeat-immutable
currently only supports basic iteration syntax:
<li repeat-immutable="item in list">...</li>
although more complex configuration will likely be introduced as needs arise.
repeat-immutable
will track object values by attaching a non-enumerable,
non-writable GUID identifier. Objects with the same structure are permitted, as
they will be assigned different identifiers. Including the same object reference
multiple times in a single list is currently not allowed as it will marked as
handled on each iteration pass at the first reference. Similarly, primitive
values are tracked by identity and therefore repeated values are not allowed.
Angular's ng-repeat
directive is not capable of iterating data structures
which are not plain arrays or objects. Furthermore, ng-repeat
uses the
$watchCollection()
function which sets up watchers not only for the collection
but also for each item in the collection in case the collection is mutated. In
the case that our collections are immutable, we should only be watching for
changes to the reference to the collection itself. Additionally, we should not
be converting to plain JS objects every time we need to re-render as Immutable
data structures are easily iterable on their own.
Install gulp globally
npm install -g gulp
To bundle sources to the dist directory:
gulp bundle
To run tests and linting:
gulp test
To generate API documentation:
gulp docs
FAQs
Support for ImmutableJS collections in Angular 1.x
The npm package immutable-angular receives a total of 27 weekly downloads. As such, immutable-angular popularity was classified as not popular.
We found that immutable-angular 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.