GithubHelp home page GithubHelp logo

make-transform's Introduction

make-transform

Make simple string based functions into browserify transforms. This does not return anything like a true stream and, as a result, is very small to browserify.

The objective was to implement just the API needed to support:

  • using it as a browserify transform
  • process.stdin.pipe(transform).pipe(process.stdout)
  • fs.createReadStream('input.js').pipe(transform).pipe(process.stdout)
  • process.stdin.pipe(transform).pipe(fs.createWriteStream('output.js'))
  • fs.createReadStream('input.js').pipe(transform).pipe(fs.createWriteStream('output.js'))

In short, this is a helper for when you are forced to interface with streams by factors outside your controll, but the actual API is just processing strings (a far simpler abstraction).

Build Status Dependency Status NPM version

Installation

npm install make-transform

API

makeTransform(fn(filename, source))

Make a browserify transform out of a function which takes filename and source as arguments and returns a string.

If a source argument is provided when called, it will just pass through to fn.

Example:

var makeTransform = require('make-transform')

module.exports = makeTransform(function (file, source) {
  return source.toLowerCase()
})

var res = module.exports('file.js', 'FUNCTION (STR) { RETURN STR.SPLIT("") }')
// res => 'function (str) { return str.split("") }'

var strm = module.exports('file.js')
strm.end('FUNCTION (STR) { RETURN STR.SPLIT("") }')
strm.pipe(concat(function (res) {
  // res => 'function (str) { return str.split("") }'
}))

makeTransform.async(fn(filename, source, callback))

Make a browserify transform out of a function which takes filename, source and callback as arguments and calls the callback with an optional error and a string.

If a source argument and callback is provided when called, it will just pass through to fn.

Example:

var makeTransform = require('make-transform')

module.exports = makeTransform.async(function (file, source, callback) {
  callback(null, source.toLowerCase())
})

module.exports('file.js', 'FUNCTION (STR) { RETURN STR.SPLIT("") }', function (err, res) {
  // res => 'function (str) { return str.split("") }'
})

var strm = module.exports('file.js')
strm.end('FUNCTION (STR) { RETURN STR.SPLIT("") }')
strm.pipe(concat(function (res) {
  // res => 'function (str) { return str.split("") }'
}))

Promises

Promise support was ommitted in an effor to keep this library ludicrously small. It's easy enough to make your own "promise transform" though:

var makeTransform = require('make-transform')
var Promise = require('promise')

function transform(file, source) {
  // return a promise for a string here
}
var streaming = makeTransform.async(Promise.nodeify(transform))
module.exports = streaming
module.exports.promise = transform

License

MIT

make-transform's People

Contributors

forbeslindesay avatar

Watchers

 avatar  avatar  avatar

make-transform's Issues

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! ๐ŸŽŠ

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If youโ€™re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didnโ€™t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didnโ€™t touch job or matrix configurations because these tend to be quite specific and complex, and itโ€™s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what youโ€™re doing it may require additional work or may not be applicable at all. Weโ€™re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, Iโ€™m a humble robot and wonโ€™t feel rejected ๐Ÿค–


FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of mocha is breaking the build ๐Ÿšจ

Version 3.3.0 of mocha just got published.

Branch Build failing ๐Ÿšจ
Dependency mocha
Current Version 3.2.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As mocha is โ€œonlyโ€ a devDependency of this project it might not break production or downstream projects, but โ€œonlyโ€ your build or test tools โ€“ preventing new deploys or publishes.

I recommend you give this issue a high priority. Iโ€™m sure you can resolve this ๐Ÿ’ช

Status Details - โŒ **continuous-integration/travis-ci/push** The Travis CI build could not complete due to an error [Details](https://travis-ci.org/ForbesLindesay/make-transform/builds/225180357)

Release Notes coverave

Thanks to all our contributors, maintainers, sponsors, and users! โค๏ธ

As highlights:

  • We've got coverage now!
  • Testing is looking less flaky \o/.
  • No more nitpicking about "mocha.js" build on PRs.

๐ŸŽ‰ Enhancements

  • #2659: Adds support for loading reporter from an absolute or relative path (@sul4bh)
  • #2769: Support --inspect-brk on command-line (@igwejk)

๐Ÿ› Fixes

  • #2662: Replace unicode chars w/ hex codes in HTML reporter (@rotemdan)

๐Ÿ” Coverage

๐Ÿ”ฉ Other

Commits

The new version differs by 89 commits0.

  • fb1687e :ship: Release v3.3.0
  • 1943e02 Add Changelog for v3.3.0
  • 861e968 Refactor literal play-icon hex code to a var
  • 1d3c5bc Fix typo in karma.conf.js
  • 9bd9389 Fix spec paths in test HTML files
  • 0a93024 Adds tests for loading reporters w/ relative/absolute paths (#2773)
  • 73929ad Comment special treatment of '+' in URL query parsing
  • e2c9514 Merge pull request #2769 from igwejk/support_inspect_break_in_opts
  • 038c636 Support --inspect-brk on command-line
  • b4ebabd Merge pull request #2727 from lamby/reproducible-build
  • 882347b Please make the build reproducible.
  • a2fc76c Merge pull request #2703 from seppevs/cover_utils_some_fn_with_tests
  • ed61cd0 cover .some() function in utils.js with tests
  • f42cbf4 Merge pull request #2701 from craigtaub/landingSpec
  • 6065242 use stubbed symbol

There are 89 commits in total.

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of mocha is breaking the build ๐Ÿšจ

The devDependency mocha was updated from 6.0.2 to 6.1.0.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

mocha is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v6.1.0

6.1.0 / 2019-04-07

๐Ÿ”’ Security Fixes

  • #3845: Update dependency "js-yaml" to v3.13.0 per npm security advisory (@plroebuck)

๐ŸŽ‰ Enhancements

  • #3766: Make reporter constructor support optional options parameter (@plroebuck)
  • #3760: Add support for config files with .jsonc extension (@sstephant)

๐Ÿ“  Deprecations

These are soft-deprecated, and will emit a warning upon use. Support will be removed in (likely) the next major version of Mocha:

๐Ÿ› Fixes

  • #3829: Use cwd-relative pathname to load config file (@plroebuck)
  • #3745: Fix async calls of this.skip() in "before each" hooks (@juergba)
  • #3669: Enable --allow-uncaught for uncaught exceptions thrown inside hooks (@givanse)

and some regressions:

๐Ÿ“– Documentation

๐Ÿ”ฉ Other

  • #3830: Replace dependency "findup-sync" with "find-up" for faster startup (@cspotcode)
  • #3799: Update devDependencies to fix many npm vulnerabilities (@XhmikosR)
Commits

The new version differs by 28 commits.

  • f4fc95a Release v6.1.0
  • bd29dbd update CHANGELOG for v6.1.0 [ci skip]
  • aaf2b72 Use cwd-relative pathname to load config file (#3829)
  • b079d24 upgrade deps as per npm audit fix; closes #3854
  • e87c689 Deprecate this.skip() for "after all" hooks (#3719)
  • 81cfa90 Copy Suite property "root" when cloning; closes #3847 (#3848)
  • 8aa2fc4 Fix issue 3714, hide pound icon showing on hover header on docs page (#3850)
  • 586bf78 Update JS-YAML to address security issue (#3845)
  • d1024a3 Update doc examples "tests.html" (#3811)
  • 1d570e0 Delete "/docs/example/chai.js"
  • ade8b90 runner.js: "self.test" undefined in Browser (#3835)
  • 0098147 Replace findup-sync with find-up for faster startup (#3830)
  • d5ba121 Remove "package" flag from sample config file because it can only be passes as CLI arg (#3793)
  • a3089ad update package-lock
  • 75430ec Upgrade yargs-parser dependency to avoid loading 2 copies of yargs

There are 28 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.