Skip to content

Commit

Permalink
v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
techjeffharris committed Mar 11, 2014
1 parent 911df4c commit 52fbeb7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 50 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
utils CHANGES
=============

# v1.0.1
* Added GetType utility so I don't have to keep limping with typeof (credit to [Angus Croll](http://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator/) )
* Prototypal is unnecessary in nodejs enviroment.
52 changes: 3 additions & 49 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,53 +39,8 @@ function extend(original, extensions) {
return original;
};


/**
* 'prototypal' creates and returns a prototypal constructor function. The
* returned constructor will return a new object spawned from the given
* parent object, initialized by 'initializer', and augmented with 'methods'
*
* prototypal(parent, initializer, methods) {...}
*
* parent:
* the parent object to extend
*
* initializer:
* the function to initialize newly constructed instances
*
* methods:
* an object containing functions to augment newly constructed instances
*
*/

function prototypal(parent, initializer, methods) {

// declare init, declare prototype, then assign to it the result
// of passing a valid parent object's prototype to Object.create
var func, prototype = Object.create(parent && parent.prototype);

if (methods) {

Object.keys(methods).forEach(function (key) {
prototype[key] = methods[key];
});
}

func = function () {
var that = Object.create(prototype);

if (typeof initializer === 'function') {
initializer.apply(that, arguments);
}
return that;
};

func.prototype = prototype;

prototype.constructor = func;

return func;

var getType = function(obj) {
return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
};

// returns that to which an XOR expression would evaluate
Expand All @@ -102,8 +57,7 @@ module.exports = {
// var cloned
// }
extend: extend,

prototypal: prototypal,
getType: getType,
XOR: XOR,

BYTE: BYTE,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "techjeffharris-utils",
"description": "handy utilties",
"version": "1.0.0",
"version": "1.0.1",
"author": "Jeff Harris <techjeffharris@gmail.com> (http://www.intangiblehost.net)",
"repository": "https://github.com/techjeffharris/utils.git",
"license": {
Expand Down

0 comments on commit 52fbeb7

Please # to comment.