New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fs.collections

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fs.collections - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

2

bower.json
{
"name": "fs.collections",
"main": "index.min.js",
"version": "2.1.1",
"version": "3.0.1",
"authors": [

@@ -6,0 +6,0 @@ "Paul Sweeney <paul@fullscreen.net"

@@ -20,3 +20,2 @@ (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<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){

this.model = BaseModel;
this.currentlyFetching = false;

@@ -255,2 +254,4 @@ this.opts = opts;

BaseCollection.prototype.model = BaseModel;
// From the Backbone source: https://github.com/jashkenas/backbone/blob/master/backbone.js#L942

@@ -260,4 +261,2 @@ // Underscore methods that we want to implement on the Collection.

// right here:
var methods = ['forEach', 'each', 'map', 'collect', 'reduce', 'foldl', 'inject', 'reduceRight', 'foldr', 'find', 'detect', 'filter', 'select', 'reject', 'every', 'all', 'some', 'any', 'include', 'contains', 'invoke', 'max', 'min', 'toArray', 'size', 'first', 'head', 'take', 'initial', 'rest', 'tail', 'drop', 'last', 'without', 'difference', 'indexOf', 'shuffle', 'lastIndexOf', 'isEmpty', 'chain'];

@@ -264,0 +263,0 @@

@@ -1,2 +0,2 @@

!function t(e,r,n){function i(u,s){if(!r[u]){if(!e[u]){var a="function"==typeof require&&require;if(!s&&a)return a(u,!0);if(o)return o(u,!0);var l=new Error("Cannot find module '"+u+"'");throw l.code="MODULE_NOT_FOUND",l}var c=r[u]={exports:{}};e[u][0].call(c.exports,function(t){var r=e[u][1][t];return i(r?r:t)},c,c.exports,t,e,r,n)}return r[u].exports}for(var o="function"==typeof require&&require,u=0;u<n.length;u++)i(n[u]);return i}({1:[function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}();r.default=["$http","BaseModel",function(t,e){var r=function(){function r(t,i){n(this,r),this.model=e,this.currentlyFetching=!1,this.opts=i,this.opts&&(this.opts.model&&(this.model=this.opts.model),this.opts.url&&(this.url=this.opts.url),this.opts.sort&&(this.sort=this.opts.sort),this.opts.comparator&&(this.comparator=this.opts.comparator),this.opts.parse&&"function"==typeof this.opts.parse&&(this.parse=this.opts.parse,delete this.opts.parse)),this.models=[],this.length=0,this.add(t,this.opts)}return i(r,[{key:"url",value:function(){}},{key:"parse",value:function(t){return t.data}},{key:"fetch",value:function(e){var r=this,n={merge:!0,parse:!0,method:"GET",url:_(this).result("url")};e=_.extend(n,e),e.params&&(e.params=_.extend({},e.params)),e.data&&(e.data=_.extend({},e.data)),this.currentlyFetching=!0;var i=t(e).then(function(t){return e.reset&&r.reset(),r.add(t,e),r});return i.finally(function(){return r.currentlyFetching=!1}),i}},{key:"eq",value:function(t){if(this.models)return this.models[t]}},{key:"get",value:function(t){return _(this.models).findWhere({id:t})}},{key:"remove",value:function(t){var e=this,r=!_(t).isArray();r&&(t=[t]);var n=[];return _(t).forEach(function(t){var r=e.indexOf(t);if(r!==-1)return n.push(t),e.models.splice(r,1),e.length--}),r?n[0]:n}},{key:"add",value:function(t,e){var r=this;if(e=_.extend({sort:!0},e),e.parse&&(t=this.parse(t)),t){var n=!_(t).isArray();t=n?[t]:t.slice();var i=[],o="undefined"==typeof e.at?this.length:e.at;return t.forEach(function(t){t=r._prepareModel(t,e);var n=r.get(t.id);return null==n?(i.push(t),r.length++,r.models.splice(o,0,t),o++):e.merge?n.set(t.attributes,e):void 0}),e.sort&&this.sort(),n?i[0]:i}}},{key:"create",value:function(t,e){var r=this.add(t,e);if(r)return r.save()}},{key:"clone",value:function(){return new this.constructor(this.toJSON(),this.opts)}},{key:"toJSON",value:function(){return _.map(this.models,function(t){return t.toJSON()})}},{key:"reset",value:function(){return this.models=[],this.length=0,this}},{key:"sort",value:function(){if(this.comparator)return this.models.sort(this.comparator)}},{key:"_prepareModel",value:function(t,e){var n=void 0;return e=_.extend({collection:this},e),t instanceof this.model||t instanceof r?(n=t,n.collection=this):n=new this.model(t,e),n}},{key:"pluck",value:function(t){return _.invoke(this.models,"get",t)}},{key:"where",value:function(t,e){if(!t)return e?void 0:[];var r="filter";return e&&(r="find"),this[r](function(e){for(var r in t)if(t[r]!==e.get(r))return!1;return!0})}},{key:"findWhere",value:function(t){return this.where(t,!0)}}]),r}(),o=["forEach","each","map","collect","reduce","foldl","inject","reduceRight","foldr","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","max","min","toArray","size","first","head","take","initial","rest","tail","drop","last","without","difference","indexOf","shuffle","lastIndexOf","isEmpty","chain"];_.each(o,function(t){return r.prototype[t]=function(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];return r.unshift(this.models),_[t].apply(_,r)}});var u=["groupBy","countBy","sortBy"];return _.each(u,function(t){return r.prototype[t]=function(e,r){var n=_.isFunction(e)?e:function(t){return t.get(e)};return _[t](this.models,n,r)}}),r}]},{}],2:[function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}var i=t("./collection.js"),o=n(i),u=t("./model.js"),s=n(u);angular.module("fs.collections",[]).factory("BaseCollection",o.default).factory("BaseModel",s.default)},{"./collection.js":1,"./model.js":3}],3:[function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},o=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}();r.default=["$http","$rootScope",function(t,e){var r=function(){function r(){var t=this,i=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],o=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];n(this,r),this.urlRoot="",this.idAttribute="id",o.parse&&(i=this.parse(i)),this._eventBus=e.$new(),this._eventBus.destuctors={},this._eventBus.$on("$destroy",function(){return _(t._eventBus.destuctors).each(function(t,e){return t.forEach(function(t){return t.unwatch()})})}),o.collection&&(this.collection=o.collection),o.urlRoot&&(this.urlRoot=o.urlRoot),o.idAttribute&&(this.idAttribute=o.idAttribute),o.defaults&&(this.defaults=o.defaults),this.attributes={},i=_.extend({},i),i=_.defaults(i,_.result(this,"defaults")),this.set(i)}return o(r,[{key:"parse",value:function(t){return t.status&&t.headers?t.data:t}},{key:"_hasIdAttribute",value:function(t){return _(Object.keys(t)).contains(this.idAttribute)}}]),o(r,[{key:"trigger",value:function(){for(var t=arguments.length,e=Array(t),r=0;r<t;r++)e[r]=arguments[r];return this._eventBus.$broadcast.apply(this._eventBus,e)}},{key:"on",value:function(t,e){this._eventBus.destuctors[t]||(this._eventBus.destuctors[t]=[]);var r=this._eventBus.destuctors[t],n=function(t,r){for(var n=arguments.length,i=Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];return e.apply(this,[r].concat(i))};return r.push({unwatch:this._eventBus.$on(t,n),original:e})}},{key:"off",value:function(t,e){var r=this._eventBus.destuctors[t]||[],n=[];return n=e?r.filter(function(t){return t.original===e}):r,n.forEach(function(t){return t.unwatch()})}},{key:"once",value:function(t,e){var r=this,n=function n(){for(var i=arguments.length,o=Array(i),u=0;u<i;u++)o[u]=arguments[u];return r.off(t,n),e.apply(r,o)};return this.on(t,n)}},{key:"has",value:function(t){return null!=this.attributes[t]}},{key:"get",value:function(t){return this.attributes[t]}},{key:"set",value:function(t,e){var r=this,n=void 0;if(!t)return this;"object"===("undefined"==typeof t?"undefined":i(t))?n=t:(n={},n[t]=e);var o={};return this._hasIdAttribute(n)&&(this.id=n[this.idAttribute]),_(n).each(function(t,e){return r.attributes[e]!==t&&(o[e]=t),r.attributes[e]=t}),this.trigger("change",this,o),_(o).each(function(t,e){return r.trigger("change:"+e,r,t)}),this}},{key:"isNew",value:function(){return null==this.id}},{key:"url",value:function(){var t=_.result(this,"urlRoot")||_.result(this.collection,"url");if(this.isNew())return t;var e=encodeURIComponent(this.id);return t+("/"===t.charAt(t.length-1)?e:"/"+e)}},{key:"toJSON",value:function(){return _.clone(this.attributes)}},{key:"fetch",value:function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],r=_.extend({},e);return _(r).defaults({method:"GET",url:_.result(this,"url")}),t(r).then(_(this.parse).bind(this)).then(_(this.set).bind(this))}},{key:"save",value:function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],r=_.extend({},e);return _(r).defaults({method:this.isNew()?"POST":"PUT",url:_.result(this,"url"),data:this.toJSON()}),t(r).then(_(this.parse).bind(this)).then(_(this.set).bind(this))}},{key:"destroy",value:function e(){var r=this,n=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.collection&&this.collection.remove(this);var e=function(){return r.trigger("destroy",r,r.collection,n),r._eventBus.$destroy()};return this.isNew()?e():(_(n).defaults({method:"DELETE",url:this.url("delete")}),t(n).then(_(this.parse).bind(this)).then(e))}}]),r}(),u=["keys","values","pairs","invert","pick","omit"];return _.each(u,function(t){return r.prototype[t]=function(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];return r.unshift(this.attributes),_[t].apply(_,r)}}),r}]},{}]},{},[2]);
!function t(e,r,n){function i(u,s){if(!r[u]){if(!e[u]){var a="function"==typeof require&&require;if(!s&&a)return a(u,!0);if(o)return o(u,!0);var l=new Error("Cannot find module '"+u+"'");throw l.code="MODULE_NOT_FOUND",l}var c=r[u]={exports:{}};e[u][0].call(c.exports,function(t){var r=e[u][1][t];return i(r?r:t)},c,c.exports,t,e,r,n)}return r[u].exports}for(var o="function"==typeof require&&require,u=0;u<n.length;u++)i(n[u]);return i}({1:[function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}();r.default=["$http","BaseModel",function(t,e){var r=function(){function e(t,r){n(this,e),this.currentlyFetching=!1,this.opts=r,this.opts&&(this.opts.model&&(this.model=this.opts.model),this.opts.url&&(this.url=this.opts.url),this.opts.sort&&(this.sort=this.opts.sort),this.opts.comparator&&(this.comparator=this.opts.comparator),this.opts.parse&&"function"==typeof this.opts.parse&&(this.parse=this.opts.parse,delete this.opts.parse)),this.models=[],this.length=0,this.add(t,this.opts)}return i(e,[{key:"url",value:function(){}},{key:"parse",value:function(t){return t.data}},{key:"fetch",value:function(e){var r=this,n={merge:!0,parse:!0,method:"GET",url:_(this).result("url")};e=_.extend(n,e),e.params&&(e.params=_.extend({},e.params)),e.data&&(e.data=_.extend({},e.data)),this.currentlyFetching=!0;var i=t(e).then(function(t){return e.reset&&r.reset(),r.add(t,e),r});return i.finally(function(){return r.currentlyFetching=!1}),i}},{key:"eq",value:function(t){if(this.models)return this.models[t]}},{key:"get",value:function(t){return _(this.models).findWhere({id:t})}},{key:"remove",value:function(t){var e=this,r=!_(t).isArray();r&&(t=[t]);var n=[];return _(t).forEach(function(t){var r=e.indexOf(t);if(r!==-1)return n.push(t),e.models.splice(r,1),e.length--}),r?n[0]:n}},{key:"add",value:function(t,e){var r=this;if(e=_.extend({sort:!0},e),e.parse&&(t=this.parse(t)),t){var n=!_(t).isArray();t=n?[t]:t.slice();var i=[],o="undefined"==typeof e.at?this.length:e.at;return t.forEach(function(t){t=r._prepareModel(t,e);var n=r.get(t.id);return null==n?(i.push(t),r.length++,r.models.splice(o,0,t),o++):e.merge?n.set(t.attributes,e):void 0}),e.sort&&this.sort(),n?i[0]:i}}},{key:"create",value:function(t,e){var r=this.add(t,e);if(r)return r.save()}},{key:"clone",value:function(){return new this.constructor(this.toJSON(),this.opts)}},{key:"toJSON",value:function(){return _.map(this.models,function(t){return t.toJSON()})}},{key:"reset",value:function(){return this.models=[],this.length=0,this}},{key:"sort",value:function(){if(this.comparator)return this.models.sort(this.comparator)}},{key:"_prepareModel",value:function(t,r){var n=void 0;return r=_.extend({collection:this},r),t instanceof this.model||t instanceof e?(n=t,n.collection=this):n=new this.model(t,r),n}},{key:"pluck",value:function(t){return _.invoke(this.models,"get",t)}},{key:"where",value:function(t,e){if(!t)return e?void 0:[];var r="filter";return e&&(r="find"),this[r](function(e){for(var r in t)if(t[r]!==e.get(r))return!1;return!0})}},{key:"findWhere",value:function(t){return this.where(t,!0)}}]),e}();r.prototype.model=e;var o=["forEach","each","map","collect","reduce","foldl","inject","reduceRight","foldr","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","max","min","toArray","size","first","head","take","initial","rest","tail","drop","last","without","difference","indexOf","shuffle","lastIndexOf","isEmpty","chain"];_.each(o,function(t){return r.prototype[t]=function(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];return r.unshift(this.models),_[t].apply(_,r)}});var u=["groupBy","countBy","sortBy"];return _.each(u,function(t){return r.prototype[t]=function(e,r){var n=_.isFunction(e)?e:function(t){return t.get(e)};return _[t](this.models,n,r)}}),r}]},{}],2:[function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}var i=t("./collection.js"),o=n(i),u=t("./model.js"),s=n(u);angular.module("fs.collections",[]).factory("BaseCollection",o.default).factory("BaseModel",s.default)},{"./collection.js":1,"./model.js":3}],3:[function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},o=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}();r.default=["$http","$rootScope",function(t,e){var r=function(){function r(){var t=this,i=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],o=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];n(this,r),this.urlRoot="",this.idAttribute="id",o.parse&&(i=this.parse(i)),this._eventBus=e.$new(),this._eventBus.destuctors={},this._eventBus.$on("$destroy",function(){return _(t._eventBus.destuctors).each(function(t,e){return t.forEach(function(t){return t.unwatch()})})}),o.collection&&(this.collection=o.collection),o.urlRoot&&(this.urlRoot=o.urlRoot),o.idAttribute&&(this.idAttribute=o.idAttribute),o.defaults&&(this.defaults=o.defaults),this.attributes={},i=_.extend({},i),i=_.defaults(i,_.result(this,"defaults")),this.set(i)}return o(r,[{key:"parse",value:function(t){return t.status&&t.headers?t.data:t}},{key:"_hasIdAttribute",value:function(t){return _(Object.keys(t)).contains(this.idAttribute)}}]),o(r,[{key:"trigger",value:function(){for(var t=arguments.length,e=Array(t),r=0;r<t;r++)e[r]=arguments[r];return this._eventBus.$broadcast.apply(this._eventBus,e)}},{key:"on",value:function(t,e){this._eventBus.destuctors[t]||(this._eventBus.destuctors[t]=[]);var r=this._eventBus.destuctors[t],n=function(t,r){for(var n=arguments.length,i=Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];return e.apply(this,[r].concat(i))};return r.push({unwatch:this._eventBus.$on(t,n),original:e})}},{key:"off",value:function(t,e){var r=this._eventBus.destuctors[t]||[],n=[];return n=e?r.filter(function(t){return t.original===e}):r,n.forEach(function(t){return t.unwatch()})}},{key:"once",value:function(t,e){var r=this,n=function n(){for(var i=arguments.length,o=Array(i),u=0;u<i;u++)o[u]=arguments[u];return r.off(t,n),e.apply(r,o)};return this.on(t,n)}},{key:"has",value:function(t){return null!=this.attributes[t]}},{key:"get",value:function(t){return this.attributes[t]}},{key:"set",value:function(t,e){var r=this,n=void 0;if(!t)return this;"object"===("undefined"==typeof t?"undefined":i(t))?n=t:(n={},n[t]=e);var o={};return this._hasIdAttribute(n)&&(this.id=n[this.idAttribute]),_(n).each(function(t,e){return r.attributes[e]!==t&&(o[e]=t),r.attributes[e]=t}),this.trigger("change",this,o),_(o).each(function(t,e){return r.trigger("change:"+e,r,t)}),this}},{key:"isNew",value:function(){return null==this.id}},{key:"url",value:function(){var t=_.result(this,"urlRoot")||_.result(this.collection,"url");if(this.isNew())return t;var e=encodeURIComponent(this.id);return t+("/"===t.charAt(t.length-1)?e:"/"+e)}},{key:"toJSON",value:function(){return _.clone(this.attributes)}},{key:"fetch",value:function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],r=_.extend({},e);return _(r).defaults({method:"GET",url:_.result(this,"url")}),t(r).then(_(this.parse).bind(this)).then(_(this.set).bind(this))}},{key:"save",value:function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],r=_.extend({},e);return _(r).defaults({method:this.isNew()?"POST":"PUT",url:_.result(this,"url"),data:this.toJSON()}),t(r).then(_(this.parse).bind(this)).then(_(this.set).bind(this))}},{key:"destroy",value:function e(){var r=this,n=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.collection&&this.collection.remove(this);var e=function(){return r.trigger("destroy",r,r.collection,n),r._eventBus.$destroy()};return this.isNew()?e():(_(n).defaults({method:"DELETE",url:this.url("delete")}),t(n).then(_(this.parse).bind(this)).then(e))}}]),r}(),u=["keys","values","pairs","invert","pick","omit"];return _.each(u,function(t){return r.prototype[t]=function(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];return r.unshift(this.attributes),_[t].apply(_,r)}}),r}]},{}]},{},[2]);
//# sourceMappingURL=index.min.js.map
{
"name": "fs.collections",
"version": "3.0.0",
"version": "3.0.1",
"description": "Backbone style models and collections for AngularJS",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -7,3 +7,2 @@ /* eslint-disable no-return-assign */

constructor (models, opts) {
this.model = BaseModel
this.currentlyFetching = false

@@ -177,2 +176,4 @@ this.opts = opts

BaseCollection.prototype.model = BaseModel
// From the Backbone source: https://github.com/jashkenas/backbone/blob/master/backbone.js#L942

@@ -179,0 +180,0 @@ // Underscore methods that we want to implement on the Collection.

@@ -60,5 +60,13 @@ /* global describe, jasmine, it, beforeEach, inject, expect, spyOn */

return expect(instance.models[0].spy).toHaveBeenCalledWith({id: 1})
}
)
})
it('should initialize new models using its extended "model" attribute', function () {
class ExtendedCollection extends Collection {}
ExtendedCollection.prototype.model = FakeModel
let instance = new ExtendedCollection([{id: 1}])
expect(instance.length).toBe(1)
expect(instance.models[0] instanceof FakeModel).toBe(true)
return expect(instance.models[0].spy).toHaveBeenCalledWith({id: 1})
})
it('should be able to handle being passed both objects and models', function () {

@@ -65,0 +73,0 @@ let instance = new Collection([{id: 1}, {id: 2}], {model: FakeModel})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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