The missing API for Javascript.

{Pure.constructor.create}

Creates constructors with an optional base prototype.

create(ctor)

  • ctor - The constructor being created.

Creates a constructor with no prototype members.

create(ctor, members)

  • ctor - The constructor being created.
  • members - The object whose own properties will be defined on the constructor's prototype.

Creates a constructor with protoype members from 'members'.

create(ctor, members, base)

  • ctor - The constructor being created.
  • members - The object whose own properties will be defined on the constructor's prototype.
  • base - The object that will be used as the base prototype chain for the constructor. If 'base' is a constructor then its prototype will be used.

Creates a constructor with a prototype chain containing 'base' and protoype members from 'members'.

{Pure.create}

Creates a new object with the specified object as its prototype.

create(o)

  • o - The object to have the new object's prototype based off of.

Creates a new object with the specified object as its prototype. If the object passed in is a primitive then it is wrapped in an object using its constructor so that the primitive becomes an object instance.

{Pure.adheresTo}

Determines if an object adheres to a specified interface or interface specification.

adheresTo(o, interfce)

  • o - The object to test.
  • interfce - An object whose interface will be used for testing or an interface spcification.

Determines if an object adheres to a specified interface or interface specification. An interface specification is an object whose property names designate the interface and the property values the type expected for the property. The 'any type' specificier '*' can be used to designate that the property must exist but can be any type (except undefined). The Pure.typeOf() function is used to test property types.

{Pure.mixin}

Copies all own properties from object(s) into an existing object. Properties with the same name will be overwritten.

mixin(o, ...)

  • o - The object to have properties copied into. If 'o' is not a valid object then an error will be thrown.
  • ... - A list of objects whose properties will be copied into 'o'. If an invalid object is encountered it will be skipped.

Copies all own properties from the list of objects into the specified object.

{Pure.typeOf}

Retrieves the true type of an object.

typeOf(o)

  • o - The object whose type will be retrieved.

Retrieves the true type of a specified object.

Object TypeReturn Value
object'object'
array'array'
string'string'
number'number'
boolean'boolean'
function'function'
undefined'undefined'
null'null'

{Pure.is____}

Convenient and intelligent type testing functions.

isString(o)

  • o - The object to test.

Determines if the specified object is a string literal or is an instance of String.

isBoolean(o)

  • o - The object to test.

Determines if the specified object is a boolean literal or is an instance of Boolean.

isNumber(o)

  • o - The object to test.

Determines if the specified object is a number literal or is an instance of Number.

isPrimitive(o)

  • o - The object to test.

Determines if the specified object is a string, boolean or number literal.

isFunction(o)

  • o - The object to test.

Determines if the specified object is a function.

isArray(o)

  • o - The object to test.

Determines if the specified object is an array literal an instance of Array.

isObject(o)

  • o - The object to test.

Determines if the specified object is an object.

isDefined(o)

  • o - The object to test.

Determines if the specified object is not null and not undefined.

isUndefined(o)

  • o - The object to test.

Determines if the specified object is either null or undefined.