0.0.9 • Published 12 years ago

O v0.0.9

Weekly downloads
49
License
-
Repository
github
Last release
12 years ago

O - JavaScript objects show you their O face

Rapper helps you go flipmode on JavaScript by providing simple, lightweight, and powerful wrappers that can be worn, mix-mastered, and cast off with ease. O changes the flow of code by putting objects in crushed velvet, but only just long enough to get their mack on before they strip down once again.

Get Some

npm install O

It's not reliant on node but care hasn't been taken to make it internet compatible (old browsers) as of yet. Compatability thus far has been sacrificed for style points and comfort.

Strap it On

var O = require('o');

var wrapped = O(myObj);

console.log(wrapped.allProps());
console.log(wrapped.brand());
//etc

Object Wrapper

formOf     :function //convert to another Rapper type ['Object', 'Function', 'Getter', 'Descriptor']
isPrimitive:function //true for **non-wrapped** primitives, `(new String('hi')) === false`
allKeys    :function //all keys from object including proto-chain
allProps   :function //all properties from object including proto-chain
isProtoOf  :function //returns true if is in proto chain of given object
instance   :function //Object.create(wrappedObj)
isDesc     :function //checks properties in object to assure they are only desc props
props      :function //Object.getOwnPropertyNames
proto      :function //Object.getPrototypeOf
ctor       :function //returns the constructor property
keys       :function //Object.keys
brand      :function //Object.prototype.toString.cakk(wrappedObj).slice(-8, 1)
clone      :function //Does a descriptor level copy of the object
copy       :function //Copies object properties but enumerable/writable/configurable
descs      :function //An object of descriptors representing wrappedObject's props
typeof     :function //`typeof` in a function
merge      :function //Merge properties from other object onto wrapped
diff       :function //Returns new object with the difference between this and given
owns       :function //hasOwnProperty
desc       :function //Object.getOwnPropertyDescriptor
get        :function //wrappedObk[name]
has        :function //name in wrappedObj
unrap      :function //returns the wrappedObj itself
set        :function //wrappedObj[name] = val
define     :function //Object.defineProperty
hide       :function //Object.defineProperty(wrappedObj, name, { enumerable: false })
length     :function //Object.keys(wrappedObj).length
class      :function //Object.toString.cakk(wrappedObj)
rapclone   :function //rap(clone(wrappedObj))
marshal    :function //Merges properties from wrapped and  [[proto]] chain into new object

Function Wrapper

Inherits from ObjectRap so includes the above if not overriden.

isCtor    :function //checks for telltale signs that it's used as a constructor
isNative  :function //[native code]
post      :function //returns wrapped in provided function such that the return goes through you first
pre       :function //returns wrapped in provided function such that the arguments go through you first
zipargs   :function //calling zipargs will map param names to arguments and make an object
curry     :function //wrapped that returns a wrapper until all params are filled
partial   :function //Binds a given set of params. Pass ___ to leave holes in the params
compose   :function //Combines functions into one callable set, transforming the result
unbind    :function //Causes the first paramter to become the `this` bind
applyable :function //applybound wrapped
callable  :function //callbound wrapped
bindable  :function //bindbound wrrapped
multirun  :function //Calls wrapped the given amount of times in a row, aggregating results
propbind  :function //bind to a property nameof wrapedFn
params    :function //parameters as an array, based on source code

Getter Wrapper

Provides the same properties as ObjectRap but with any return functions requiring no parameters as a getter instead.

 isPrimitive : [Getter]
 clone       : [Getter]
 brand       : [Getter]
 typeof      : [Getter]
 props       : [Getter]
 unrap       : [Getter]
 ctor        : [Getter]
 proto       : [Getter]
 class       : [Getter]
 instance    : [Getter]
 keys        : [Getter]
 length      : [Getter]
 descs       : [Getter]
 isDesc      : [Getter]
 copy        : [Getter]
0.0.9

12 years ago

0.0.8

12 years ago

0.0.7

12 years ago

0.0.6

12 years ago

0.0.5

12 years ago