Skip to content
Browse files

updated deps

  • Loading branch information...
1 parent 11e4fe1 commit 6c47fbca2fe6336c2e42268a88658e9abf59752f @gushov committed Jan 24, 2013
Showing with 75 additions and 28 deletions.
  1. +71 −24 dist/lilmodel.js
  2. +2 −2 dist/lilmodel.min.js
  3. +2 −2 package.json
View
95 dist/lilmodel.js
@@ -1,4 +1,4 @@
-/*! lilmodel - v0.0.7 - 2013-01-18
+/*! lilmodel - v0.0.8 - 2013-01-24
* Copyright (c) 2013 August Hovland <gushov@gmail.com>; Licensed MIT */
(function (ctx) {
@@ -131,6 +131,29 @@ module.exports = {
},
+ some: function (thing, func, ctx) {
+
+ var type = this.typeOf(thing);
+ var keys;
+
+ if (type === 'array' && thing.length) {
+
+ return thing.some(func, ctx);
+
+ } else if (type === 'object') {
+
+ keys = thing ? Object.keys(thing) : [];
+
+ return keys.some(function (name, i) {
+ return func.call(ctx, name, thing[name], i);
+ });
+
+ }
+
+ return false;
+
+ },
+
map: function (thing, func, ctx) {
var type = this.typeOf(thing);
@@ -154,61 +177,85 @@ module.exports = {
},
- walk: function (target, source, func, fill) {
+ withOut: function (arr, value) {
- var self = this;
+ var result = [];
- var walkObj = function (target, source) {
+ this.each(arr, function (element) {
+
+ if (element !== value) {
+ result.push(element);
+ }
+
+ });
+
+ return result;
+
+ },
+ walk: function (target, source, func, fill) {
+
+ var self = this;
+
+ var walkObj = function (target, source) {
+
self.each(source, function (name, obj) {
step(target[name], obj, name, target);
});
-
+
};
-
+
var step = function (target, source, name, parent) {
-
+
var type = self.typeOf(source);
-
+
if (type === 'object') {
-
+
if (!target && parent && fill) {
target = parent[name] = {};
}
walkObj(target, source);
-
+
} else {
func.call(parent, target, source, name);
}
-
+
};
-
+
step(target, source);
-
+
},
- extend: function (obj, src) {
+ extend: function () {
+
+ var args = Array.prototype.slice.call(arguments);
+ var target = args.shift();
- this.walk(obj, src, function (target, src, name) {
- this[name] = src;
- }, true);
+ this.each(args, function (src) {
- return obj;
+ this.each(src, function (name, value) {
+ target[name] = value;
+ });
+
+ }, this);
+
+ return target;
},
- defaults: function (obj, defaults) {
+ defaults: function (target, defaults) {
- this.walk(obj, defaults, function (target, src, name) {
+ this.each(defaults, function (name, value) {
- if (!target) {
- this[name] = src;
+ var type = this.typeOf(target[name]);
+ if (type === 'undefined' || type === 'null') {
+ target[name] = value;
}
- }, true);
+ }, this);
- return obj;
+ return target;
},
View
4 dist/lilmodel.min.js
@@ -1,3 +1,3 @@
-/*! lilmodel - v0.0.7 - 2013-01-18
+/*! lilmodel - v0.0.8 - 2013-01-24
* Copyright (c) 2013 August Hovland <gushov@gmail.com>; Licensed MIT */
-(function(e){"use strict";function r(e,t){if(t.indexOf(".")===-1)return t;t=t.split("/"),e=e?e.split("/"):[],e.pop(),t[0]==="."&&t.shift();while(t[0]==="..")t.shift(),e.pop();return e.concat(t).join("/")}var t={},n={};e.provide=function(e,r,i){return i?t[e]=r:n[e]=r},e.require=function(i,s){var o,u,a=s||i;return n[a]?n[a]:(o=n[a]={},u={exports:o},t[a](function(t){return e.require(t,r(a,t))},u,o),n[a]=u.exports)}})(this),provide("lil_",function(e,t,n){t.exports={typeOf:function(e){var t=typeof e;return t==="object"&&(t=Array.isArray(e)?"array":t,t=e===null?"null":t),t},each:function(e,t,n){var r=this.typeOf(e),i;r==="array"&&e.length?e.forEach(t,n):r==="object"&&(i=e?Object.keys(e):[],i.forEach(function(r,i){t.call(n,r,e[r],i)}))},every:function(e,t,n){var r=this.typeOf(e),i;return r==="array"&&e.length?e.every(t,n):r==="object"?(i=e?Object.keys(e):[],i.every(function(r,i){return t.call(n,r,e[r],i)})):!1},map:function(e,t,n){var r=this.typeOf(e),i=[];return r==="array"&&e.length?e.map(t,n):(r==="object"&&(i={},this.each(e,function(e,n,r){i[e]=t.call(this,e,n,r)},n)),i)},walk:function(e,t,n,r){var i=this,s=function(e,t){i.each(t,function(t,n){o(e[t],n,t,e)})},o=function(e,t,o,u){var a=i.typeOf(t);a==="object"?(!e&&u&&r&&(e=u[o]={}),s(e,t)):n.call(u,e,t,o)};o(e,t)},extend:function(e,t){return this.walk(e,t,function(e,t,n){this[n]=t},!0),e},defaults:function(e,t){return this.walk(e,t,function(e,t,n){e||(this[n]=t)},!0),e},match:function(e,t){var n=!0;return this.walk(e,t,function(e,t){n=e===t}),n},pick:function(e,t){var n={};return t=this.typeOf(t)==="array"?t:Object.keys(t),this.each(t,function(t){n[t]=e&&e[t]}),n}}},!0),provide("lilobj/arr",function(e,t,n){function i(){var e=[];return e.push.apply(e,arguments),e.__proto__=i.prototype,e}var r=e("lil_");i.prototype=[],i.prototype.isA=function(e){function t(){}return t.prototype=e,this instanceof t},i.prototype.extend=function(e){i.prototype=this;var t=new i;return r.each(e,function(n){t[n]=e[n]}),t},i.prototype.create=function(){i.prototype=this;var e=new i;return e.construct!==undefined&&e.construct.apply(e,arguments),e},t.exports=new i},!0),provide("lilobj/obj",function(e,t,n){var r=e("lil_");t.exports={isA:function(e){function t(){}return t.prototype=e,this instanceof t},extend:function(e){var t=Object.create(this);return r.each(e,function(e,n){t[e]=n}),t},create:function(){var e=Object.create(this);return e.construct!==undefined&&e.construct.apply(e,arguments),e}}},!0),provide("lilobj",function(e,t,n){var r=e("./lilobj/obj"),i=e("./lilobj/arr");t.exports={obj:r,arr:i}},!0),provide("vladiator",function(e,t,n){var r=e("lil_"),i={required:function(e){return typeof e!="undefined"&&e!==null},array:function(e){return Array.isArray(e)},number:function(e){return typeof e=="number"},string:function(e){return typeof e=="string"},"boolean":function(e){return typeof e=="boolean"},length:function(e,t,n){var r=!t||e.length>=t,i=!n||e.length<=n;return r&&i},gte:function(e,t){return e>=t}},s=function(e,t){var n={isValid:!0};return(e[0]==="required"||i.required(t))&&r.every(e,function(e){var r,s=[];return typeof e!="string"?(r=e[0],s=e.slice(1)):r=e,s.unshift(t),i[r].apply(null,s)?!0:(n.isValid=!1,n.error=r,!1)}),n.$=t,n};t.exports=s},!0),provide("lilmodel/collection",function(e,t,n){function o(e,t,n){return function(r,i){var s=!r&&t.create(i);n.call(e,r,s)}}var r=e("lilobj").arr,i=e("lil_"),s=e("./syncr");t.exports=r.extend({construct:function(e){i.each(e,function(e){this.push(this.model.create(e))},this),this.validate()},validate:function(){var e={isValid:!0,error:[]};return i.each(this,function(t){var n=t.validate();e.error.push(n.error),e.isValid=e.isValid&&n.isValid}),e},add:function(e){var t;e.isA&&e.isA(this.model)?t=e:t=this.model.create(e),this.push(t)},remove:function(e){var t;i.each(this,function(n,r){i.match(n,e)&&(t=r)}),typeof t=="number"&&this.splice(t,1)},get:function(e){return this.filter(function(t){return i.match(t,e)})},find:function(e,t,n){var r=s();this.query=e,r("find",this,o(n,this,t))}})},!0),provide("lilmodel/model",function(e,t,n){function u(e){return this.$[e]}function a(e,t){var n=this.children&&this.children[e];n&&n.create&&typeof t=="object"?this.$[e]=n.create(t):n&&typeof t=="object"?this.$[e]=this.create(t):n||(this.$[e]=t)}function f(e,t,n){return function(r,i){var s=r?null:t.create(i);n.call(e,r,s)}}var r=e("lilobj").obj,i=e("lil_"),s=e("vladiator"),o=e("./syncr");t.exports=r.extend({construct:function(e){this.$={};var t=i.map(this.rules,function(e,t){return{enumerable:!0,get:u.bind(this,e),set:a.bind(this,e)}},this);Object.defineProperties(this,t),e=i.pick(e,this.rules),i.defaults(e,this.defaults),i.each(e,function(e,t){this[e]=t},this),this.validate()},validate:function(){var e={isValid:!0,error:{}};return i.each(this.rules,function(t,n){var r=this[t],i;r&&r.validate?i=r.validate():(i=s(n,r),r=i.$),e.error[t]=i.error,e.isValid=e.isValid&&i.isValid},this),e},save:function(e,t){var n=o(),r=this.$._id?"update":"create",i=this.validate();i.isValid?n(r,this,f(t,this,e)):e.call(t,i.error,this)},fetch:function(e,t){var n=o();n("fetch",this,f(t,this,e))},destroy:function(e,t){var n=o();n("destroy",this,f(t,this,e))}})},!0),provide("lilmodel/syncr",function(e,t,n){var r=function(e,t,n){n(null,t)};t.exports=function(e){return e&&(r=e),r}},!0),provide("lilmodel",function(e,t,n){var r=e("./lilmodel/syncr"),i=e("./lilmodel/model"),s=e("./lilmodel/collection");t.exports={syncr:r,model:i,collection:s}},!0);
+(function(e){"use strict";function r(e,t){if(t.indexOf(".")===-1)return t;t=t.split("/"),e=e?e.split("/"):[],e.pop(),t[0]==="."&&t.shift();while(t[0]==="..")t.shift(),e.pop();return e.concat(t).join("/")}var t={},n={};e.provide=function(e,r,i){return i?t[e]=r:n[e]=r},e.require=function(i,s){var o,u,a=s||i;return n[a]?n[a]:(o=n[a]={},u={exports:o},t[a](function(t){return e.require(t,r(a,t))},u,o),n[a]=u.exports)}})(this),provide("lil_",function(e,t,n){t.exports={typeOf:function(e){var t=typeof e;return t==="object"&&(t=Array.isArray(e)?"array":t,t=e===null?"null":t),t},each:function(e,t,n){var r=this.typeOf(e),i;r==="array"&&e.length?e.forEach(t,n):r==="object"&&(i=e?Object.keys(e):[],i.forEach(function(r,i){t.call(n,r,e[r],i)}))},every:function(e,t,n){var r=this.typeOf(e),i;return r==="array"&&e.length?e.every(t,n):r==="object"?(i=e?Object.keys(e):[],i.every(function(r,i){return t.call(n,r,e[r],i)})):!1},some:function(e,t,n){var r=this.typeOf(e),i;return r==="array"&&e.length?e.some(t,n):r==="object"?(i=e?Object.keys(e):[],i.some(function(r,i){return t.call(n,r,e[r],i)})):!1},map:function(e,t,n){var r=this.typeOf(e),i=[];return r==="array"&&e.length?e.map(t,n):(r==="object"&&(i={},this.each(e,function(e,n,r){i[e]=t.call(this,e,n,r)},n)),i)},withOut:function(e,t){var n=[];return this.each(e,function(e){e!==t&&n.push(e)}),n},walk:function(e,t,n,r){var i=this,s=function(e,t){i.each(t,function(t,n){o(e[t],n,t,e)})},o=function(e,t,o,u){var a=i.typeOf(t);a==="object"?(!e&&u&&r&&(e=u[o]={}),s(e,t)):n.call(u,e,t,o)};o(e,t)},extend:function(){var e=Array.prototype.slice.call(arguments),t=e.shift();return this.each(e,function(e){this.each(e,function(e,n){t[e]=n})},this),t},defaults:function(e,t){return this.each(t,function(t,n){var r=this.typeOf(e[t]);if(r==="undefined"||r==="null")e[t]=n},this),e},match:function(e,t){var n=!0;return this.walk(e,t,function(e,t){n=e===t}),n},pick:function(e,t){var n={};return t=this.typeOf(t)==="array"?t:Object.keys(t),this.each(t,function(t){n[t]=e&&e[t]}),n}}},!0),provide("lilobj/arr",function(e,t,n){function i(){var e=[];return e.push.apply(e,arguments),e.__proto__=i.prototype,e}var r=e("lil_");i.prototype=[],i.prototype.isA=function(e){function t(){}return t.prototype=e,this instanceof t},i.prototype.extend=function(e){i.prototype=this;var t=new i;return r.each(e,function(n){t[n]=e[n]}),t},i.prototype.create=function(){i.prototype=this;var e=new i;return e.construct!==undefined&&e.construct.apply(e,arguments),e},t.exports=new i},!0),provide("lilobj/obj",function(e,t,n){var r=e("lil_");t.exports={isA:function(e){function t(){}return t.prototype=e,this instanceof t},extend:function(e){var t=Object.create(this);return r.each(e,function(e,n){t[e]=n}),t},create:function(){var e=Object.create(this);return e.construct!==undefined&&e.construct.apply(e,arguments),e}}},!0),provide("lilobj",function(e,t,n){var r=e("./lilobj/obj"),i=e("./lilobj/arr");t.exports={obj:r,arr:i}},!0),provide("vladiator",function(e,t,n){var r=e("lil_"),i={required:function(e){return typeof e!="undefined"&&e!==null},array:function(e){return Array.isArray(e)},number:function(e){return typeof e=="number"},string:function(e){return typeof e=="string"},"boolean":function(e){return typeof e=="boolean"},length:function(e,t,n){var r=!t||e.length>=t,i=!n||e.length<=n;return r&&i},gte:function(e,t){return e>=t}},s=function(e,t){var n={isValid:!0};return(e[0]==="required"||i.required(t))&&r.every(e,function(e){var r,s=[];return typeof e!="string"?(r=e[0],s=e.slice(1)):r=e,s.unshift(t),i[r].apply(null,s)?!0:(n.isValid=!1,n.error=r,!1)}),n.$=t,n};t.exports=s},!0),provide("lilmodel/collection",function(e,t,n){function o(e,t,n){return function(r,i){var s=!r&&t.create(i);n.call(e,r,s)}}var r=e("lilobj").arr,i=e("lil_"),s=e("./syncr");t.exports=r.extend({construct:function(e){i.each(e,function(e){this.push(this.model.create(e))},this),this.validate()},validate:function(){var e={isValid:!0,error:[]};return i.each(this,function(t){var n=t.validate();e.error.push(n.error),e.isValid=e.isValid&&n.isValid}),e},add:function(e){var t;e.isA&&e.isA(this.model)?t=e:t=this.model.create(e),this.push(t)},remove:function(e){var t;i.each(this,function(n,r){i.match(n,e)&&(t=r)}),typeof t=="number"&&this.splice(t,1)},get:function(e){return this.filter(function(t){return i.match(t,e)})},find:function(e,t,n){var r=s();this.query=e,r("find",this,o(n,this,t))}})},!0),provide("lilmodel/model",function(e,t,n){function u(e){return this.$[e]}function a(e,t){var n=this.children&&this.children[e];n&&n.create&&typeof t=="object"?this.$[e]=n.create(t):n&&typeof t=="object"?this.$[e]=this.create(t):n||(this.$[e]=t)}function f(e,t,n){return function(r,i){var s=r?null:t.create(i);n.call(e,r,s)}}var r=e("lilobj").obj,i=e("lil_"),s=e("vladiator"),o=e("./syncr");t.exports=r.extend({construct:function(e){this.$={};var t=i.map(this.rules,function(e,t){return{enumerable:!0,get:u.bind(this,e),set:a.bind(this,e)}},this);Object.defineProperties(this,t),e=i.pick(e,this.rules),i.defaults(e,this.defaults),i.each(e,function(e,t){this[e]=t},this),this.validate()},validate:function(){var e={isValid:!0,error:{}};return i.each(this.rules,function(t,n){var r=this[t],i;r&&r.validate?i=r.validate():(i=s(n,r),r=i.$),e.error[t]=i.error,e.isValid=e.isValid&&i.isValid},this),e},save:function(e,t){var n=o(),r=this.$._id?"update":"create",i=this.validate();i.isValid?n(r,this,f(t,this,e)):e.call(t,i.error,this)},fetch:function(e,t){var n=o();n("fetch",this,f(t,this,e))},destroy:function(e,t){var n=o();n("destroy",this,f(t,this,e))}})},!0),provide("lilmodel/syncr",function(e,t,n){var r=function(e,t,n){n(null,t)};t.exports=function(e){return e&&(r=e),r}},!0),provide("lilmodel",function(e,t,n){var r=e("./lilmodel/syncr"),i=e("./lilmodel/model"),s=e("./lilmodel/collection");t.exports={syncr:r,model:i,collection:s}},!0);
View
4 package.json
@@ -2,7 +2,7 @@
"author": "August Hovland <gushov@gmail.com>",
"name": "lilmodel",
"description": "A li'l model wrapper",
- "version": "0.0.8",
+ "version": "0.0.9",
"repository": {
"type": "git",
"url": "git://github.com/gushov/lilmodel.git"
@@ -29,4 +29,4 @@
"scripts": {
"test": "grunt buster"
}
-}
+}

0 comments on commit 6c47fbc

Please sign in to comment.
Something went wrong with that request. Please try again.