# callify

> Create browserify transforms that change or inline external module function calls

Latest version **0.3.0** (published 2014-08-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install callify
pnpm add callify
yarn add callify
bun add callify
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2014-08-15 |
| First published | 2013-11-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Matt McKegg |
| Maintainers | mmckegg |
| Keywords | browserify, inline, brfs, transform, precompile |

## Links

- npm: https://www.npmjs.com/package/callify
- Repository: https://github.com/mmckegg/callify
- Issues: https://github.com/mmckegg/callify/issues
- npm.io page: https://npm.io/package/callify

## Dependencies (4)

- [esprima](https://npm.io/package/esprima.md) ^1.2.2
- [falafel](https://npm.io/package/falafel.md) ^0.3.1
- [through](https://npm.io/package/through.md) ^2.3.4
- [syntax-error](https://npm.io/package/syntax-error.md) ^1.1.1

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.3.0 (latest) — 2014-08-15
- 0.2.0 — 2014-02-10
- 0.1.1 — 2013-12-11
- 0.1.0 — 2013-12-09
- 0.0.0 — 2013-11-05

## README

callify
===

Create browserify transforms that change or inline external module function calls.

Uses [falafel](https://github.com/substack/node-falafel) for scanning calls to specified modules.

[![NPM](https://nodei.co/npm/callify.png?compact=true)](https://nodei.co/npm/callify/)

## Example

Find all fs.readFileSync calls and inline the result:

```js
// transform.js

var callify = require('callify')
var staticEval = require('static-eval')

module.exports = callify({

  // specify in the module names you want to hook and what to do with the node
  
  'fs': function(node, params){
    if (params.calls[1] === 'readFileSync'){
      var args = getArgs(node, params)
      var content = readFileSync.apply(this, args)
      node.update(JSON.stringify(content))
    }
  }
})

function getArgs(node, params){
  return node.arguments.map(function(arg){ 
    return staticEval(arg, {
      __filename: params.file,
      __dirname: path.dirname(params.file)
    }) 
  })
}
```

```js
// entry.js
var filesys = require("fs")
var content = filesys.readFileSync(__dirname + "/content.txt", "utf8")
```

```bash
$ browserify entry.js -t ./transform.js > output.js
```

```js
// output.js
var filesys = require("fs")
var content = "file contents"
```

---
_Source: https://npm.io/package/callify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
