Skip to content

Commit

Permalink
Revert "Update description"
Browse files Browse the repository at this point in the history
This reverts commit 4d46a42.
  • Loading branch information
Fredrick Galoso committed May 29, 2012
1 parent 4d46a42 commit 12a7daa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 103 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Crackle: JavaScript comparator, equality, and utility functions
Crackle: jQuery comparator, equality, and utility functions
Copyright (c) 2012 Fredrick Galoso http://fredrickgaloso.me

Permission is hereby granted, free of charge, to any person obtaining
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Crackle
=======

JavaScript predicate, comparator, equality, and utility functions
jQuery comparator, equality, and JavaScript utility functions
114 changes: 13 additions & 101 deletions crackle.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Crackle
* JavaScript predicate, comparator, equality, and utility functions
* jQuery comparator, equality, and JavaScript utility functions
* git@github.com:wayoutmind/crackle.git
*/

Expand All @@ -19,110 +19,30 @@
difference: function(self) {
return {
from: function(that) {
if (Array.prototype.slice.call(arguments).length === 1) {
return self.filter(function(e) {
return (that.indexOf(e) < 0);
});
} else {
var that = Array.prototype.slice.call(arguments);
return self.filter(function(e) {
return (that.indexOf(e) < 0);
});
}
return self.filter(function(e) {
return (that.indexOf(e) < 0);
});
}
};
},
/**
* Assertions and contracts
*/
is: function(self) {
return {
/**
* Return {Boolean} that an element exists in an Array
* @param self {Object}
* @param collection {Array}
*/
in: function(collection) {
if (Array.prototype.slice.call(arguments).length === 1) {
return collection.some(function(e) {
return (self === e);
});
} else {
return Array.prototype.slice.call(arguments).some(function(e) {
return (self === e);
});
}
},
/**
* Return {Boolean} that a predicate is satisfied
* for each element in an Array
* @param self {Array}
* @param predicate {Function}
*/
all: function(predicate) {
for (var i = 0; i < self.length; i++) {
if (!predicate(self[i])) {
return false;
}
} return true;
},
/**
* Return {Boolean} that a type is satisfied
* for each element in an Array
* @param self {Array}
* @param type {String}
*/
typeof: function(type) {
if (Array.isArray(self)) {
for (var i = 0; i < self.length; i++) {
if (typeof self[i] !== type) {
return false;
}
} return true;
} else {
return (typeof self === type);
}
},
/**
* Return {Boolean} that each element in an Array
* is an instanceof of a type
* @param self {Array}
* @param type {Constructor}
*/
instanceof: function(type) {
if (Array.isArray(self)) {
for (var i = 0; i < self.length; i++) {
if (!(self[i] instanceof type)) {
return false;
}
} return true;
} else {
return (self instanceof type);
}
}
};
}
};

if ($ !== null) {
/**
* Return jQuery objects from HTML string(s)
* @param self {String Array} or {String}
*/
Crackle.parse = function(self) {
parse: function(self) {
if (Array.isArray(self)) {
return self.map(function(html) {
return $(html);
});
} else {
return $(self);
}
};
},
/**
* Return HTML strings from jQuery object(s)
* @param self {jQuery Object Array} or {jQuery Object}
*/
Crackle.stringify = function(self) {
stringify: function(self) {
if (typeof self === 'string') {
return self;
} else if (Array.isArray(self)) {
Expand All @@ -132,11 +52,11 @@
} else {
return self.outerHTML;
}
};
},
/**
* Fuzzy similarity comparator
*/
Crackle.similar = function(self) {
compare: function(self) {
return {
to: function(that) {
if (Crackle.stringify(self) === Crackle.stringify(that)) {
Expand All @@ -148,17 +68,9 @@
}
}
};
};
}
}
};

if (typeof window !== 'undefined') {
window.Crackle = Crackle;
} else {
exports = module.exports = Crackle;
}
window.Crackle = Crackle;

})(
(function() {
return (typeof jQuery !== 'undefined') ? jQuery : null;
})()
);
})(jQuery);

0 comments on commit 12a7daa

Please sign in to comment.