graspify

2.0.3 • Public • Published

graspify Build Status Code Climate

Browserify transform to make source code replacements using grasp.

Installing

$ npm install --save-dev graspify

Usage

Define replacements in package.json:

{
  "main": "./index.js",
  "graspify": [
    ["equery", "__ + __", "{{.l}} - {{.r}}"],
    ["squery", "#myVar", "myVariable"]
  ],
  "dependencies": {
    "graspify": "^0.0.1"
  }
}

Run graspify transform:

$ browserify -t graspify index.js

Sometimes it is handy to perform global transform, to affect nested modules:

$ browserify -g graspify index.js.

API

Graspify can be used programmatically:

b.transform(graspify, replacements);

Pass replacements as a second optional argument. It will be merged with the ones defined in package.json.

var browserify = require('browserify');
var b = browserify('./entry.js');
var graspify = require('graspify');
 
b.transform(graspify, [
  ["squery", "#myVar", "myVariable"],
  ["equery", "__ + __", "{{.r}} + {{.l}}"],
 
  //you can also pass a replacement funtion
  ["equery", "require($module)", function(){
    return "require('stub')"
  }]
])

NPM

Package Sidebar

Install

npm i graspify

Weekly Downloads

1

Version

2.0.3

License

Unlicensed

Last publish

Collaborators

  • dfcreative