Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-data

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-data - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

8

CHANGELOG.md

@@ -0,1 +1,9 @@

##### 1.2.0 - 02 November 2014
###### Backwards compatible API changes
- #208 - ng-repeat $$hashKey affecting hasChanges
###### Backwards compatible bug fixes
- #223 - need to update lastModified when an item is re-injected
##### 1.1.0 - 30 October 2014

@@ -2,0 +10,0 @@

2

package.json
{
"name": "angular-data",
"description": "Data store for Angular.js.",
"version": "1.1.0",
"version": "1.2.0",
"homepage": "http://angular-data.pseudobry.com",

@@ -6,0 +6,0 @@ "repository": {

@@ -11,3 +11,3 @@ ## angular-data [![Stories in Backlog](https://badge.waffle.io/jmdobry/angular-data.svg?label=backlog&title=Backlog)](http://waffle.io/jmdobry/angular-data) [![Stories in Ready](https://badge.waffle.io/jmdobry/angular-data.svg?label=ready&title=Ready)](http://waffle.io/jmdobry/angular-data) [![Stories in progress](https://badge.waffle.io/jmdobry/angular-data.svg?label=in%20progress&title=In%20Progress)](http://waffle.io/jmdobry/angular-data)

__Latest Release:__ [1.1.0](https://github.com/jmdobry/angular-data/releases/tag/1.1.0)
__Latest Release:__ [1.2.0](https://github.com/jmdobry/angular-data/releases/tag/1.2.0)

@@ -14,0 +14,0 @@ Angular-data is finally 1.0.!

@@ -199,2 +199,18 @@ function lifecycleNoop(resourceName, attrs, cb) {

* @doc property
* @id DSProvider.properties:defaults.ignoredChanges
* @name defaults.ignoredChanges
* @description
* Array of strings or regular expressions which can be ignored when diffing two objects for changes
*
* ## Example:
* ```js
* // ignore $ or _ prefixed changes
* DSProvider.defaults.ignoredChanges = [/\$|\_/];
* ```
*
* @value {array} ignoredChanges Array of changes to ignore. Defaults to ignoring $ prefixed changes: [/\$/]
*/
Defaults.prototype.ignoredChanges = [/\$/];
/**
* @doc property
* @id DSProvider.properties:defaults.beforeValidate

@@ -201,0 +217,0 @@ * @name defaults.beforeValidate

@@ -38,21 +38,34 @@ function errorPrefix(resourceName) {

* @param {string|number} id The primary key of the item of the changes to retrieve.
* @param {=object} options Optional configuration. Properties:
*
* - `{array=}` - `blacklist` - Array of strings or RegExp that specify fields that should be ignored when checking for changes.
*
* @returns {object} The changes of the item of the type specified by `resourceName` with the primary key specified by `id`.
*/
function changes(resourceName, id) {
function changes(resourceName, id, options) {
var DS = this;
var DSUtils = DS.utils;
var definition = DS.definitions[resourceName];
id = DS.utils.resolveId(DS.definitions[resourceName], id);
if (!DS.definitions[resourceName]) {
options = options || {};
id = DSUtils.resolveId(DS.definitions[resourceName], id);
if (!definition) {
throw new DS.errors.NER(errorPrefix(resourceName) + resourceName);
} else if (!DS.utils.isString(id) && !DS.utils.isNumber(id)) {
} else if (!DSUtils.isString(id) && !DSUtils.isNumber(id)) {
throw new DS.errors.IA(errorPrefix(resourceName) + 'id: Must be a string or a number!');
} else if (!DSUtils.isObject(options)) {
throw new DS.errors.IA(errorPrefix(resourceName) + 'options: Must be an object!');
}
options = DSUtils._(definition, options);
var item = DS.get(resourceName, id);
if (item) {
DS.store[resourceName].observers[id].deliver();
var diff = DS.utils.diffObjectFromOldObject(item, DS.store[resourceName].previousAttributes[id]);
DS.utils.forEach(diff, function (changeset, name) {
var diff = DSUtils.diffObjectFromOldObject(item, DS.store[resourceName].previousAttributes[id], options.ignoredChanges);
DSUtils.forEach(diff, function (changeset, name) {
var toKeep = [];
DS.utils.forEach(changeset, function (value, field) {
DSUtils.forEach(changeset, function (value, field) {
if (!angular.isFunction(value)) {

@@ -62,5 +75,5 @@ toKeep.push(field);

});
diff[name] = DS.utils.pick(diff[name], toKeep);
diff[name] = DSUtils.pick(diff[name], toKeep);
});
DS.utils.forEach(DS.definitions[resourceName].relationFields, function (field) {
DSUtils.forEach(DS.definitions[resourceName].relationFields, function (field) {
delete diff.added[field];

@@ -67,0 +80,0 @@ delete diff.removed[field];

@@ -119,2 +119,3 @@ var observe = require('../../../lib/observe-js/observe-js');

var item = DS.get(definition.name, id);
var initialLastModified = item ? resource.modified[id] : 0;

@@ -168,2 +169,3 @@ if (!item) {

resource.saved[id] = DS.utils.updateTimestamp(resource.saved[id]);
resource.modified[id] = initialLastModified && resource.modified[id] === initialLastModified ? DS.utils.updateTimestamp(resource.modified[id]) : resource.modified[id];
definition.afterInject(definition.name, item);

@@ -274,5 +276,7 @@ injected = item;

injected = _inject.call(DS, definition, resource, attrs, options);
resource.collectionModified = DS.utils.updateTimestamp(resource.collectionModified);
});
} else {
injected = _inject.call(DS, definition, resource, attrs, options);
resource.collectionModified = DS.utils.updateTimestamp(resource.collectionModified);
}

@@ -279,0 +283,0 @@

@@ -59,2 +59,17 @@ var DSErrors = require('./errors');

var find = require('mout/array/find');
var isRegExp = require('mout/lang/isRegExp');
function isBlacklisted(prop, blacklist) {
if (!blacklist || !blacklist.length) {
return false;
}
var matches = find(blacklist, function (blItem) {
if ((isRegExp(blItem) && blItem.test(prop)) || blItem === prop) {
return prop;
}
});
return !!matches;
}
module.exports = ['$q', function ($q) {

@@ -69,2 +84,3 @@ return {

isEmpty: require('mout/lang/isEmpty'),
isRegExp: isRegExp,
toJson: angular.toJson,

@@ -83,2 +99,3 @@ fromJson: angular.fromJson,

filter: require('mout/array/filter'),
find: find,
toLookup: require('mout/array/toLookup'),

@@ -150,3 +167,3 @@ remove: require('mout/array/remove'),

},
diffObjectFromOldObject: function (object, oldObject) {
diffObjectFromOldObject: function (object, oldObject, blacklist) {
var added = {};

@@ -159,5 +176,10 @@ var removed = {};

if (newValue !== undefined && newValue === oldObject[prop])
if (isBlacklisted(prop, blacklist)) {
continue;
}
if (newValue !== undefined && newValue === oldObject[prop]) {
continue;
}
if (!(prop in object)) {

@@ -168,10 +190,16 @@ removed[prop] = undefined;

if (newValue !== oldObject[prop])
if (newValue !== oldObject[prop]) {
changed[prop] = newValue;
}
}
for (var prop2 in object) {
if (prop2 in oldObject)
if (prop2 in oldObject) {
continue;
}
if (isBlacklisted(prop2, blacklist)) {
continue;
}
added[prop2] = object[prop2];

@@ -178,0 +206,0 @@ }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc