GithubHelp home page GithubHelp logo

h2non / hu Goto Github PK

View Code? Open in Web Editor NEW
20.0 5.0 3.0 159 KB

Small, generic functional helper library for node.js and browsers

License: MIT License

JavaScript 35.49% wisp 61.43% Makefile 3.08%
wisp functional-programming curry memoize clojure clojurescript javascript

hu's People

Contributors

bitdeli-chef avatar dependabot[bot] avatar h2non avatar rafinskipg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

hu's Issues

Fix isFinite node 0.8 issue

isFinite invalid:
     TypeError: Cannot call method 'isFinite' of undefined
      at Object.isFinite (/home/travis/build/h2non/hu/lib/type.js:49:24)
      at Context.<anonymous> (undefined:100:17)
      at callFn (/home/travis/build/h2non/hu/node_modules/mocha/lib/runnable.js:223:21)
      at Test.Runnable.run (/home/travis/build/h2non/hu/node_modules/mocha/lib/runnable.js:214:7)
      at Runner.runTest (/home/travis/build/h2non/hu/node_modules/mocha/lib/runner.js:374:10)
      at Runner.runTests.next (/home/travis/build/h2non/hu/node_modules/mocha/lib/runner.js:452:12)
      at next (/home/travis/build/h2non/hu/node_modules/mocha/lib/runner.js:299:14)
      at Runner.hooks (/home/travis/build/h2non/hu/node_modules/mocha/lib/runner.js:309:7)
      at next (/home/travis/build/h2non/hu/node_modules/mocha/lib/runner.js:247:23)
      at Runner.hook (/home/travis/build/h2non/hu/node_modules/mocha/lib/runner.js:276:5)
      at process.startup.processNextTick.process._tickCallback (node.js:245:9)

Debounce bug

Hi Mr h2non

I 've detected a bug in the debounce function
when I do

var createBonus = hu.debounce(function(){
    console.log('creating boinus', bonuses.length);
    bonuses.push(EL.getEntity('bonus',[canvas.width, Math.random() * (canvas.height - 39)]));
  }, 5000);

the createBonus() function is used on a canvas game, then it's crucial that it's only being called after X seconds. Otherwise is called like 60 times per second.

What is happening right now is (on the game loop)

  • It's only being called after 5 seconds
  • After that is called 60 times per second

What should be happening is

  • It's called at first
  • It's called after 5 seconds
  • It's called after 10 seconds, etc etc

If you are too busy, i can try to look into it this weekend, otherwise i will be very grateful for your fix

cheers

Add more collections functions

Add collection helper utility functions, like filter and map, which should also support arrays

  • pluck
  • reduce
  • omit
  • contains
  • reject

Surrogate pair support

(console.log (chars "123あいう🐜🐞🐝𤭢"))

ideal

[ '1', '2', '3', 'あ', 'い', 'う', '🐜', '🐞', '🐝', '𤭢' ]

reality

[ '1', '2', '3', 'あ', 'い', 'う', '�', '�', '�', '�', '�', '�', '�', '�' ]

aVoid the numerous void

In the transpiled js, due to the inclusion of the namespace (I don't know exactly why), it generates this output:

void 0;
void 0;
void 0;
void 0;
void 0;
void 0;
void 0;
void 0;
void 0;

Remove them or I kick the dog in my picture!

hu.curry

Hi, maybe I missunderstood something, but I expected "curry" to work in other way

var hu = require('hu');
//HU CURRY SUM
var sum = hu.curry(function(a,b){
  return a+b;
})

var mas2 = sum(2);

console.log(mas2(40));
console.log(mas2(50));
console.log(mas2(10));

//REAL CURRIED SUM
var sum2 = function(a){
  return function(b){
      return a+b;
  }
}

var mas2_2 = sum2(2);

console.log(mas2_2(40));
console.log(mas2_2(50));
console.log(mas2_2(10));

And this is the result:

//HU
42
42
42
//REAL
42
52
12

Add array functions

  • pull
  • filter
  • reject
  • reverse
  • unique
  • compact (clean)
  • fold
  • toArray
  • last
  • flatten

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.