An essential JavaScript library for node.js and browsers
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
test Merge pull request #36 from danfooo/fixtest May 23, 2014
.travis.yml update dependencies, travis, istanbul, badges! Mar 19, 2014 beautify Mar 20, 2014
defer.js Having more tests fixes bugs. I swear. Fix typo in kindOf result. Mar 19, 2014
index.js back to embedded hasEnumBug check for prototype keys assignment Apr 8, 2014
map.js update dependencies, travis, istanbul, badges! Mar 19, 2014


Package Info NPM Version Coverage Status Build Status Dependencies Status DevDependencies Status

  1. fundamental, basic, essential.
  2. make (something) ready for use or action.
  3. 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.

Modules Overview

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 Emitter = require("prime/emitter")

var Cat = prime({
    inherits: Animal,
    mixin: Emitter,
    say: function(){
        return "meaow" +


The event emitter.

var Emitter = require("prime/emitter")

var Dog = prime({
    inherits: Animal,
    mixin: Emitter,
    say: function(){
        var word = "wuff" +
        this.emit("say", word)
        return word

var barkley = new Dog

barkley.on("say", function(word){
    console.log("barkley barked", word)


Map-like 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"


Optimized timeouts / immediates / animationFrames.

var defer = require("prime/defer")

defer.frame(function() {
    console.log('on next animation frame');

defer.immediate(function() {
    console.log('on platform next tick.');

defer.timeout(function() {
}, 500);

When all else fails, read the full documentation.