unit-fns

After experimenting with shaders and other languages like Rust to see what they could offer in terms of performance for graphics and audio, I still missed the tooling and ecosystem that we as web developers are used to. Unit-fns is the answer to what happ

Usage no npm install needed!

<script type="module">
  import unitFns from 'https://cdn.skypack.dev/unit-fns';
</script>

README

Unit-fns provides composable primitives that make it easy to generate complex numerical patterns with little code.

Motivation

After experimenting with shaders and other languages like Rust to see what they could offer in terms of performance for graphics and audio, I still missed the tooling and ecosystem that we as web developers are used to. Unit-fns is the answer to what happens when an elegant API is the primary goal. It is currently pre version 1, the API is experimental and might change without notice.

Get started

Install

npm install --save unit-fns
# or
yarn add unit-fns

Use

import { toUnit } from 'unit-fns';

console.log(toUnit(10)); // 1

Examples

API

  • Most functions receive and return numbers in the 0-1 range. Let's call a number that is in that range a Unit.
  • Functions that can be pure, are pure.
  • The argument order is optimized for partial application.