Giter VIP home page Giter VIP logo

invoke.js's Introduction

Invoke.js

A JavaScript Library.

Warning: this library is incomplete.

License

MIT License

Requirements

Browser Support

Browser Version
Internet Explorer 11+
Chrome, Firefox, Safari, Opera latest

Modules

  • Core
  • Request - ajax
  • Event - event model

Core (core.js)

- function Class(ctor) // create a new class
- function Class.extend(extend,ctor)

- function $.remove(arr,value)
- function $.each(obj,cb)
- function $.mix(obj,mix)
- class $.Delegate(list)
  - method .call(...)
  - method .add(fn)
  - method .remove(fn)

Examples

var Animal=Class(function(name){
    this.name=name;
}).method({
    speak:function(things){
        return "My name is "+this.name+" and I like "+things;
    }
});

var nemo=Animal("Nemo");
nemo.speak("swimming");
// -> "My name is Nemo and I like swimming"

var Dog=Class.extend(Animal,function(name){
    this.super(name);
}).method({
    speak:function(stuff){
        return this.super.invoke(this,"speak",stuff).toUpperCase()+"!";
    }
});

var rex=Dog("Rex");
rex.speak("barking");
// -> "MY NAME IS REX AND I LIKE BARKING!"
$.remove([1,2,3],2);
// -> [1,3]

// only the first matched item will be removed
$.remove([4,6,9,4,2,1],4);
// -> [6,9,4,2,1]

$.each({
    a:1,
    b:2
},function(key,value){
    console.log(key,value);
});
// "a" 1
// "b" 2

$.mix({},{name:"test"});
// -> {name:"test"}

$.mix({age:16},{age:20});
// -> {age:20}

$.mix({},[{name:"test"},{age:30}]);
// -> {name:"test",age:30}

var delegate=$.Delegate([function(){
    console.log(1);
},function(){
    console.log(2);
}]);
delegate.add(function(){
    console.log(3);
});
delegate.add(function(name){
    console.log(name);
});

delegate.length;
// -> 4

delegate.call("test");
// 1
// 2
// 3
// "test"

var fn=delegate.call;
fn();
// also be ok.

invoke.js's People

Contributors

lixiaoyan avatar

Stargazers

skys215 avatar

Watchers

James Cloos avatar  avatar

invoke.js's Issues

TODO list

TODO

  • core.js
    • add delegate class
  • request.js
    • promise.abort
    • response & error class
    • set response-type
    • support other send(...)
    • support timeout

FIXME

  • request.js
    • how to send plain string? ($.load)

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.