Git Product home page Git Product logo

saber-lang's Issues

增加 bind 函数

@treelite 看到你saber-viewport的更新,发现原来iOS 5.1.4之前不支持bind,估计你本地写好了,求更新 😆

throttle实现逻辑有问题

function throttle(fn, wait, options) {
        options = options || {};

        var context;
        var args;
        var timer;
        var last = 0;

        var task = function () {
            last = options.leading === false ? 0 : Date.now();
            fn.apply(options.context || context, args);

            // 这里应该加上重置 timer = null;
        };

        return function () {
            context = this;
            args = arguments;

            var now = Date.now();

            if (!last && options.leading === false) {
                last = now;
            }

            var remaining = wait - (now - last);
            if (remaining <= 0 || remaining > wait) {
                timer = clearTimeout(timer);
                last = now;
                fn.apply(options.context || context, args);
            }
            else if (!timer && options.trailing !== false) {
                timer = setTimeout(task, remaining);
            }
        };
    }

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.