├── .gitignore ├── .jscsrc ├── .jshintrc ├── .npmignore ├── README.md ├── bower.json ├── demo ├── app.js ├── bower.json └── index.html ├── dist ├── immutable.js └── immutable.min.js ├── lib └── immutable.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # Compiled binary addons (http://nodejs.org/api/addons.html) 20 | build/Release 21 | 22 | # Dependency directory 23 | # Commenting this out is preferred by some people, see 24 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- 25 | node_modules 26 | 27 | # Users Environment Variables 28 | .lock-wscript 29 | 30 | bower_components -------------------------------------------------------------------------------- /.jscsrc: -------------------------------------------------------------------------------- 1 | { 2 | "requireCurlyBraces": ["else", "for", "while", "do", "try", "catch"], 3 | "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], 4 | "requireSpacesInFunctionExpression": { 5 | "beforeOpeningCurlyBrace": true 6 | }, 7 | "disallowMultipleVarDecl": true, 8 | "requireSpacesInsideObjectBrackets": "allButNested", 9 | "disallowSpacesInsideArrayBrackets": true, 10 | "disallowSpacesInsideParentheses": true, 11 | "disallowSpaceAfterObjectKeys": true, 12 | "disallowQuotedKeysInObjects": true, 13 | "requireSpaceBeforeBinaryOperators": ["?", "+", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="], 14 | "disallowSpaceAfterBinaryOperators": ["!"], 15 | "requireSpaceAfterBinaryOperators": ["?", ",", "+", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="], 16 | "disallowSpaceBeforeBinaryOperators": [","], 17 | "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], 18 | "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], 19 | "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], 20 | "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], 21 | "disallowImplicitTypeConversion": ["numeric", "binary", "string"], 22 | "disallowKeywords": ["with", "eval"], 23 | "disallowMultipleLineBreaks": true, 24 | "disallowKeywordsOnNewLine": ["else"], 25 | "requireLineFeedAtFileEnd": true, 26 | "disallowTrailingWhitespace": true, 27 | "excludeFiles": ["node_modules/**", "bower_components/**"], 28 | "validateIndentation": 2 29 | } -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "browser": true, 3 | "jquery": true, 4 | "node": true, 5 | "esnext": true, 6 | "bitwise": true, 7 | "camelcase": true, 8 | "curly": true, 9 | "eqeqeq": true, 10 | "indent": 2, 11 | "latedef": true, 12 | "noarg": true, 13 | "newcap": false, 14 | "quotmark": "single", 15 | "unused": true, 16 | "strict": true, 17 | "trailing": true, 18 | "smarttabs": true, 19 | "white": true, 20 | "freeze": true, 21 | "immed": true, 22 | "noempty": true, 23 | "plusplus": true, 24 | "undef": true, 25 | "laxbreak": true, 26 | "maxdepth": 3, 27 | "loopfunc": true, 28 | "maxcomplexity": 9, 29 | "maxlen": 80, 30 | "maxparams": 4 31 | } 32 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | demo/ 2 | lib/ 3 | **/.* 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Angular Immutable 2 | 3 | Angular Immutable is a simple directive, which allows binding of [Immutable.js](https://github.com/facebook/immutable-js) collections. 4 | 5 | # Demo 6 | 7 | ```javascript 8 | var sampleApp = angular.module('sampleApp', ['immutable']); 9 | 10 | function SampleCtrl($scope) { 11 | $scope.data = Immutable.List([1, 2, 3]); 12 | } 13 | 14 | sampleApp.controller('SampleCtrl', SampleCtrl); 15 | ``` 16 | 17 | ```html 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | 31 | ``` 32 | 33 | ### Result 34 | 35 | * 1 36 | * 2 37 | * 3 38 | 39 | 40 | You can find additional [immutable-js tools for Angular here](https://github.com/PaySavvy/immutable-angular). 41 | 42 | # License 43 | 44 | MIT 45 | 46 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-immutable", 3 | "version": "0.1.3", 4 | "main": "./dist/immutable.js", 5 | "homepage": "https://github.com/mgechev/angular-immutable", 6 | "authors": [ 7 | "mgechev " 8 | ], 9 | "description": "Directive for binding to Immutable.js collections", 10 | "license": "MIT", 11 | "dependencies": { 12 | "angular": ">=1.1.4" 13 | }, 14 | "ignore": [ 15 | "**/.*", 16 | "node_modules", 17 | "bower_components", 18 | "test", 19 | "tests", 20 | "demo", 21 | "lib" 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /demo/app.js: -------------------------------------------------------------------------------- 1 | /* global Immutable, angular */ 2 | 3 | var sampleApp = angular.module('sampleApp', ['immutable']); 4 | 5 | function buildCollection(size) { 6 | 'use strict'; 7 | var res = []; 8 | for (var i = 0; i < size; i += 1) { 9 | res.push(Math.random()); 10 | } 11 | return res; 12 | } 13 | 14 | function SampleCtrl($scope, $timeout) { 15 | 'use strict'; 16 | var runs = 0; 17 | var SIZE = 50000; 18 | var TOTAL = 100; 19 | var start = Date.now(); 20 | $scope.list = Immutable.List(buildCollection(SIZE)); 21 | function changeCollection() { 22 | if (runs >= TOTAL) { 23 | console.log('%cDone!', 24 | 'font-size: 50px; color: blue;' + 25 | 'font-weight: bold; font-family: impact;'); 26 | console.log('%c' + ((Date.now() - start) / 1000) + 27 | ' seconds required.', 'font-size: 30px; color: red;'); 28 | return; 29 | } 30 | $timeout(function () { 31 | var idx = Math.random() * SIZE - 1; 32 | $scope.list = $scope.list.set(idx, Math.random()); 33 | runs += 1; 34 | changeCollection(); 35 | }, 0); 36 | } 37 | changeCollection(); 38 | } 39 | 40 | sampleApp.controller('SampleCtrl', SampleCtrl); 41 | 42 | -------------------------------------------------------------------------------- /demo/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "demo", 3 | "version": "0.0.0", 4 | "authors": [ 5 | "mgechev " 6 | ], 7 | "license": "MIT", 8 | "private": true, 9 | "ignore": [ 10 | "**/.*", 11 | "node_modules", 12 | "bower_components", 13 | "test", 14 | "tests" 15 | ], 16 | "dependencies": { 17 | "angular": "~1.3.14", 18 | "immutable": "~3.7.5" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /dist/immutable.js: -------------------------------------------------------------------------------- 1 | (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.angularImmutable = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o