purefuncs

1.0.3 • Public • Published

WORK IN PROGRESS - DO NOT USE YET

Purefuncs

build dependencies devDependencies

license npm version npm downloads

Automatically extract pure functions from your javascript code for unit testing.

Installation

  npm install --save purefuncs

cli usage

Given:

// file: src/example.js
import {asd, boo} from 'asd'
import math from 'somewhere'
const z = 2;
function foo() {
  const x = 3 + z;
  function bla() {
    const f = 5 + asd;
    return x + 1;
  }
  function tada() {
    return x + math.sin(x);
  }
}

Run :

$ purefuncs src/example.js -o test/purefuncs/example.js

Output:

// file: test/purefuncs/example.js
export const foo = ({asd, math, z}) => () => {
  const x = 3 + z;
  function bla() {
    const f = 5 + asd;
    return x + 1;
  }
  function tada() {
    return x + math.sin(x);
  }
}
 
export const foo$bla = ({asd, x}) => () => {
  const f = 5 + asd;
  return x + 1;
}
 
export const foo$tada = ({math, x}) => () => {
  return x + math.sin(x);
}

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i purefuncs

Weekly Downloads

1

Version

1.0.3

License

MIT

Last publish

Collaborators

  • enkilabs