GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - glathoud/transfun: Merging loops for speed in JavaScript

BranchesTags
Open more actions menu

Latest commit

 

History

143 Commits
143 Commits

Folders and files

NameName
Last commit message
Last commit date
build
build
 
 
misc/d_performance_feasability
misc/d_performance_feasability
 
 
plugin
plugin
 
 
rsrc_web
rsrc_web
 
 
test
test
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
_npm_baby_steps.txt
_npm_baby_steps.txt
 
 
build.sh
build.sh
 
 
index.html
index.html
 
 
package.json
package.json
 
 
test.html
test.html
 
 
test.js
test.js
 
 
transfun.js
transfun.js
 
 

Repository files navigation

transfun.js

transfun.js is a JavaScript library that lets you write map/filter/reduce code that runs much faster than the equivalent native map/filter/reduce code:

speedup

Usage

Instead of passing function arguments to the native array methods map/filter/reduce to produce a result value in 1 step:

var result = arr.map((x) => x.p).filter((x) => x != null).reduce((a,b) => a + b);

...transfun.js uses a 2-step approach: first generate very fast code, then call it:

var appfun = map( '.p' ).filter( '!=null' ).reduce( '+' );
var result = appfun( arr ); // very fast!

Usage with functions

transfun.js also supports normal function arguments:

var appfun = map((x) => x.p ).filter((x) => x!=null ).reduce((out,v) => out+v );
var result = appfun( arr ); // fast!

...but there is a performance cost. However, this is still much faster than the native array methods. For more about this topic, see an article about transducers in JavaScript

Merging loops for speed

transfun.js automatically merges consecutive loops into one loop, then generates fast code for that loop (similar to stream fusion in Haskell).

Extensibility

A domain-specific language is used to define map/filter/reduce. With this language, library users can define other transformations: sum, and, or...

For the hurried ones

...you can jump directly to the speed results

More about this

http://glat.info/transfun/

Node.js package

https://www.npmjs.com/package/transfun

License

The Boost License apply, as described in the file LICENSE.

About

Merging loops for speed in JavaScript

glat.info/transfun

Topics

code-generationjavascriptlanguageloopmerging-loopsoptimizationperformance

Resources

Readme
BSL-1.0 license
Activity

Stars

44 stars

Watchers

2 watching

Forks

2 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.