Giter Club home page Giter Club logo

prime's Introduction

#prime |prīm|

  1. fundamental, basic, essential.
  2. make (something) ready for use or action.
  3. archetypal, prototypical, typical, classic.

Description

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.

prime

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" + Cat.parent.say.call(this)
    }
})

prime/emitter

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)
})

prime/map

Simple WeakMap-like object.

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"

prime/type

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"

prime/shell

Wraps every type in a special function containing every available method. Use valueOf() / toString() to get the bare value.

var _ = require("prime/shell")
_([10, 20, 30]).indexOf(1).times(function(n){}).valueOf() // 10
document.title = _(["hello-mootools"]).get(0).camelize()

prime/array

A composite module of all the methods modules. Available methods: every, filter, forEach, indexOf, map, remove, slice, some

var array = require("prime/array")
array.indexOf([1,2,3], 1)
array([1,2,3]).indexOf(1)

Requiring individual methods as generics:

var indexOf = require("prime/array/indexOf")
indexOf([1,2,3], 1)

prime/object

A composite module of all the methods modules. Available methods: count, create, every, filter, forIn, forOwn, indexOf, keys, map, mixIn, remove, some, values

var object = require("prime/object")
object.count({a:1})
object({a:1}).count()

Requiring individual methods as generics:

var count = require("prime/object/count")
count({a:1})

prime/string

A composite module of all the methods modules. Available methods: camelize, capitalize, clean, escape, hyphenate, trim

var string = require("prime/string")
string.trim("  asdfg  ")
string("  asdfg  ").trim()

Requiring individual methods as generics:

var trim = require("prime/string/trim")
trim(" asdfg ")

prime/number

A composite module of all the methods modules. Available methods: limit, random, round, times

var fn = require("prime/number")
number.times(10, function(n){})
number(10).times(function(n){})

Requiring individual methods as generics:

var times = require("prime/number/times")
times(10, function(n){})

prime/function

A composite module of all the methods modules. Available methods: bind

var fn = require("prime/function")
fn.bind(function(){}, object)
fn(function(){}).bind(object)

Requiring individual methods as generics:

var bind = require("prime/function/bind")
bind(function(){}, object)

prime/date

A composite module of all the methods modules. Available methods: now

var date = require("prime/date")
date.now()

Requiring individual methods as generics:

var now = require("date/now")
now()

Build Status

prime's People

Contributors

kamicane avatar arian avatar ibolmo avatar gcheung55 avatar cpojer avatar kentaromiura avatar subtlegradient avatar timwienk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.