clamp.js (written in ES6)
Install:
npm install clamp.js
Run tests
npm test
Returns a function that clamps input values to range [min <= x <= max]. Useful for data structures like arrays. Swapping min and max is allowed and will be corrected.
with simple arrays:
; 12345; // [1,2,3,3,3]
Can be used with frp libraries (e.g. Bacon.js, RxJS, Kefir.js). Examples are written with Bacon.js
in frp:
; ; let stream = Bacon ; // every 1000ms stream emits a value which is mapped on clamp() stream; // result -> sequence of values over time: 1,2,3,3,3
Further reading on functional reactive programming:
Copyright
Copyright © 2015 Maximilian Heinz, contributors. Released under the MIT License