Git Product home page Git Product logo

jstools's Introduction

JsTools

一些零散的JS小工具

JsPlus

JS基础扩展库,请移步这里 JsPlus

jQuery-Plug

一些jQuery插件,请移步这里 jQuery-Plug

  • jquery-pause jQuery链式调用时暂停指定时间再执行后面的操作

asyncFunc

管理异步函数的执行,降低多层异步函数及大量异步函数执行时的复杂度。

用事件监听触发的机制代替异步函数的回调关系,简化多层异步函数的逻辑。
  • eventclass() 获取一个控制器实例
  • listen 监听事件
  • trigger 触发事件
  • fnQueue 函数队列控制器
var evtFile = eventclass()//获取一个控制器实例
, fileQueue = evtFile.fnQueue(3); //初始化一个队列管理器,3 代表同时最多执行3个异步函数,不传默认为 1。

//监听一个事件,事件名为getFile。
evtFile.listen("getFile", function(data, id){
  /*
    data: 事件触发时给的参数,有且只有一个
    id: 第几次触发。
  */
  //body...
});

//给队列管理器添加一个异步任务
fileQueue.push(function(queue){//queue为队列管理器对象
  //geturl代表一个异步获取文件的函数。
  geturl("fileurl", function(data){
    evtFile.trigger("getFile", data);//异步执行完成后,触发getFile事件
    queue.end();//通知队列管理器当前任务完成。
  });
});

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.