Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Readme
Use factories to fabricate AMD, CommonJS and UMD modules.
Fume is a code generation tool which allows you to:
Write your code inside factory functions which receive dependencies as a list of arguments. Fume will use your factories to generate AMD, CJS and UMD compatible modules.
Fume will try to auto-magically detect inter-factory dependencies in your files. You can also provide platform-based annotations in your source code.
Install with npm install -g fume
require('fume')
for programmatic usage, or use the CLI tool:
fume [input(s)] -s [path] -s [path] ... --amdify --cjsify --umdify
[input]: Input file path(s)
-s (--sibling): Path of a sibling factory
-a (--amdify): generate an AMD module
-c (--cjsify): generate a CJS module
-a (--umdify): generate a UMD module
-o (--out): output directory (optional if input is one file)
You can use the CLI in two modes:
Single factory:
Build an AMD or a CJS module from a single factory. You may pass in a list of
sibling factories which will be analyzed for automatic dependency
resolution. If no output directory is specified, the result will be written
to the standard output.
Multiple factories: Pass multiple inputs to generate a module for each factory. Factories may be inter-dependent. You may pass in a list of sibling factories which will be analyzed for automatic dependency resolution. Results will be written to the specified output directory.
Annotations are specified in a comment right before the factory function.
Annotation: @name
Sets the name of the factory. Will be used to resolve dependencies.
Example:
foo.module.js:
/* @name foo */
function factory(bar){ /* ... */ }
bar.module.js:
/* @name bar */
function factory(){ /* ... */ }
Generated AMD module for foo
:
define(['./bar.module'], function factory(bar) {
/* ... */
});
Annotation: @prefer
Specify which dependency to use in case of ambiguity.
Example:
foo.js:
/**
* @name foo
* @prefer bar bar-2.0
*/
function factory(bar){ /* ... */ }
bar-1.0/bar.js:
/* @name bar */
function factory(){ /* ... */ }
bar-2.0/bar.js:
/* @name bar */
function factory(){ /* ... */ }
Note that both bar-1.0/bar
and bar-2.0/bar
are annotated with the name
bar
.
Generated AMD module for foo
:
define(['./bar-1.0/bar'], function factory(bar) {
/* ... */
});
Annotation: @amd
, @cjs
Specify how a dependency should be located when your factory is generated as an AMD module or as a CJS module.
Example:
foo.js:
/**
* @name foo
* @amd $ jquery
* @cjs $ jquery
* @amd _ lodash-amd
* @cjs _ lodash-node
*/
function factory($, _){ /* ... */ }
Generated AMD module for foo
:
define([
'jquery',
'lodash-amd'
], function factory($, _) {
/* ... */
});
Generated CJS module for foo
:
module.exports = function factory($, _) {
/* ... */
}(require('jquery'), require('lodash-node'));
Notice how the lodash dependency _
is located differently for CJS and AMD.
FAQs
Use factories to fabricate AMD and CommonJS modules
The npm package fume receives a total of 1 weekly downloads. As such, fume popularity was classified as not popular.
We found that fume demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.