#prime |prīm|
- fundamental, basic, essential.
- make (something) ready for use or action.
- archetypal, prototypical, typical, classic.
prime is an Object Oriented JavaScript library. It helps you with prototypal inheritance and contains generic utilities for every-day JavaScripting.
No Native JavaScript Objects were harmed in the making of this library.
A short overview of the available modules. For more information, refer to the documentation.
The function to create new primes.
var prime = require("prime")
var Animal = prime({
say: function(){
return "!!"
}
})
var Cat = prime({
inherits: Animal,
say: function(){
return "meaow" + Cat.parent.say.call(this)
}
})
The base shell. As you require more shells, the base shell will be augmented. Requiring specific shells gives you access to generic methods as well.
var array = require("prime/shell/array")
array.indexOf([1,2,3], 3) // 3
var _ = require("prime/shell")
_([1,2,3]).remove(1).each(function(number){
console.log(number)
})
The event emitter.
var Emitter = require("prime/emitter")
var Dog = prime({
inherits: Animal,
say: function(){
var word = "wuff" + Dog.parent.say.call(this)
this.emit("say", word)
return word
}
})
Dog.implement(new Emitter)
var barkley = new Dog
barkley.on("say", function(word){
console.log("barkley barked", word)
})
Simple WeakMap implementation.
var Map = require("prime/map")
var map = new Map()
map.set(domElement, "header")
map.set(domElement2, "footer")
map.get(domElement) // "header"
map.get(domElement2) // "footer"
Type checker.
var type = require("prime/type")
type("string") // "string"
type([]) // "array"
type(function(){}) // "function"
type(/regexp/) // "regexp"
type(new Date) // "date"
type(10) // "number"
type(false) // "boolean"
type({}) // "object"
type(arguments) // "object"
type(null) // "null"
type(undefined) // "null"
type(NaN) // "null"
Array methods.
require("prime/shell/array")
Object methods.
require("prime/shell/object")
String methods.
require("prime/shell/string")
Number methods.
require("prime/shell/number")
Function methods.
require("prime/shell/function")
Regexp methods.
require("prime/shell/regexp")
Date methods.
require("prime/shell/date")