Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

cram

cujojs3910.8.3

An AMD-compatible build tool.

cram, curl, cujo, amd, build, bundle, commonjs, module

readme

cram.js

Note: cram.js --> RaveJS

We are very excited about RaveJS, the successor to curl.js and cram.js. At its core, rave uses an ES6 Loader, rather than an AMD loader. However, rave can load many types of modules, including AMD. Therefore, rave will work with your application's AMD modules.

Rave's most exciting feature, however, is it's ability to eliminate the drudgery of bootstrapping and maintaining modern, modular web applications. If you've built a non-trivial AMD-based web app, you should be excited about rave, too.

Rave is definitely the future, so we're putting all of our effort into ensuring that RaveJS is as awesome as it can possibly be. Watch these RaveJS github projects to stay up to date:

This means that all development for curl.js and cram.js has stopped. For the foreseeable future, we will continue to respond to issues on github, as well as in the #cujojs room on freenode. However, keep in mind that there will be no further development, so some issues might not be resolved fully.

If you're as excited as we are about the future, consider helping us improve the curl-to-rave migration guide. There are many ways to architect curl+cram-based applications, so your experience migrating your app from curl+cram to rave is extremely valuable to other curl+cram users.

Also, if you are interested in becoming the lead maintainer of curl.js and/or cram.js, please let us know on #cujojs!

cujoJS resource assembler

See the docs/ folder for instructions and useful information.

New! gulp integration via gulp-cram by @bclozel!

Installation

node.js

npm install --save cram

To run cram from any folder:

npm install --global cram

Bower

TBD

Release notes

0.8.3

  • Add deprecation notice.
  • Add links to Rave Starters.
  • Add a link to the migration guide.
  • Update links to gulp-cram and bclozel

0.8.2

  • Fix module parsing code to stop prematurely detecting the end of an AMD define when there are regexp literals inside parentheses.
  • Only declare global define() during bundling to help isolate problems with UMD modules running under node (as with gulp and grunt).
  • Separate argument-parsing code from cramming code so logic to run as a module or as a command-line tool can be done more sanely.

0.8.1

  • Fix logic to detect whether cram is running as an npm task and ensure that the promise returned from the API only resolves once the bundle is created.
  • Stop appending to the cached AST data. It should be overwritten.

0.8.0

  • Add a minimal JavaScript API.
  • Correct regression: --exclude CLI option now works again.
  • Handle when factory args > dependent module ids when simplifying AMD defines. For instance, the curl/loader/cjsm11 cram plugin adds an extra arg now.

0.7.12

  • Stop failing when plugins output more than one define().

0.7.11

  • Fix compile bug that prevented use of css! plugin.
  • Start using when.js 2.x.
  • Fix configuration merging errors when inspecting both html and run.js.

0.7.10

  • Ensure that baseUrl and output are converted to absolute paths so node doesn't try to resolve them using node_modules logic.

0.7.9

  • Bug fix: plugins are now responsible for resolving url/filepath.
  • Bug fix: Normalize r-value require()s when using loaders, too.
  • Bug fix: Infer appRoot from run.js file, not just index.html. Improve logged messages a bit, too.
  • Bug fix: Excluded modules don't get compiled anymore. Force 'curl' and 'curl/_privileged' to be excluded in all cases.

0.7.8

  • AMD modules are now published to npm, so manually running bower is no longer necessary.
  • Failing to supply some AMD configuration properties no longer causes cram.js to throw. (Thanks Blaine!)

0.7.7

  • Lots of fixes to the code that groks html files.
  • Internal refactoring and reorganization

0.7.6

  • Use same logic as curl.js when assigning configuration to modules that may be loaded by a plugin or module loader.
  • Add a legacy loader example.
  • Stop detecting code such as goog.require('id') as a CommonJS-style require('id').

0.7.5

  • Improve support for i18n and CommonJS modules via curl.js 0.8
  • Improve module parsing (fixes some issues with lodash).
  • Parse literal RegExps better.
  • Include simple example apps.
  • Find build override json files without absolute paths.
  • Fix many other minor things.

changelog

2.7.0

  • Internal changes to reduce overall memory usage, along with minor performance improvements.

2.7.0

  • Added promise.catch and promise.finally as synonyms for promise.otherwise and promise.ensure. (#212)
  • New browserify build for those using globals. (#209)
  • Added ender support to package.json. (#223)
  • Fix compatibility with PhantomJS's CommonJS module support. (#226)
  • Fix Sauce Labs tests for pull requests. (#216)
  • Added bower.json ignore to trim files installed via bower. (#193)

2.6.0

  • New promise.done allows consuming the ultimate value at the end of a promise chain while ensuring that any errors are thrown to the host environment so you get loud stack traces.
  • when/node/function bindCallback and liftCallback now behave more like standard node-style APIs in that they allow exceptions to propagate to the host environment for loud stack traces.

2.5.1

  • ensure now ignores non-functions, like then does, for consistency. (#207)

2.5.0

2.4.1

  • New MutationObserver scheduler further reduces "time-to-first-handler" in modern browsers. (#198)
    • Also, this works around a horrible IE10 bug (desktop and mobile) that renders setImmediate, MessageChannel, and postMessage unusable as fast task schedulers. Many thanks to @plaa and @calvinmetcalf for their help in discovering the problem and working out a solution. (#197)

2.4.0

  • Experimental support for vert.x 2.x. Should now run in vert.x >= 1.1.0.
  • New when.isPromiseLike as the more accurately-named synonym for when.isPromise.
  • DEPRECATED: when.isPromise. It can only tell you that something is "promise-like" (aka "thenable") anyway. Use the new, more accurately-named when.isPromiseLike instead.
  • Fix for promise monitor reporting extra unhandled rejections for when.all and when.map.

2.3.0

  • New promise.tap for adding side effects to a promise chain.
  • New MessageChannel scheduler reduces "time-to-first" handler, in environments that support it.
  • Performance optimizations for promise resolution.
  • Internal architecture improvements to pave the way for when.js 3.0.0.

2.2.1

  • Fix for when.defer().reject() bypassing the unhandled rejection monitor. (#166)
  • Fix for when/function, when/callbacks, and when/node/function not preserving thisArg. (#162)
  • Doc clarifications for promise.yield. (#164)

2.2.0

  • New experimental promise monitoring and debugging via when/monitor/console.
  • New when.promise(resolver) promise creation API. A lighter alternative to the heavier when.defer()
  • New bindCallback and liftCallback in when/node/function for more integration options with node-style callbacks.

2.1.1

  • Quote internal usages of promise.yield to workaround .NET minifier tools that don't yet understand ES5 identifier-as-property rules. See #157

2.1.0

  • New when.settle that settles an array of promises, regardless of whether the fulfill or reject.
  • New when/guard generalized concurrency guarding and limiting
  • New promise.inspect for synchronously getting a snapshot of a promise's state at a particular instant.
  • Significant performance improvements when resolving promises with non-primitives (Arrays, Objects, etc.)
  • Experimental vert.x support
  • DEPRECATED: onFulfilled, onRejected, onProgress handler arguments to when.all, when.any, when.some. Use the returned promise's then() (or otherwise(), ensure(), etc) to register handlers instead.
    • For example, do this: when.all(array).then(onFulfilled, onRejected) instead of this: when.all(array, onFulfilled, onRejected). The functionality is equivalent.

2.0.1

  • Account for the fact that Mocha creates a global named process. Thanks Narsul

2.0.0

  • Fully asynchronous resolutions.
  • Promises/A+ compliance.
  • New when/keys module with all() and map() for object keys/values.
  • New promise.ensure as a better, and safer, replacement for promise.always. See discussion as to why promise.always is mistake-prone.
    • DEPRECATED: promise.always
  • lift() is now the preferred name for what was bind() in when/function, when/node/function, and when/callbacks.
    • DEPRECATED: bind() in when/function, when/node/function, and when/callbacks. Use lift() instead.

1.8.1

1.8.0

1.7.1

  • Removed leftover internal usages of deferred.then.
  • when/debug allows configuring the set of "fatal" error types that will be rethrown to the host env.

1.7.0

  • DEPRECATED: deferred.then is deprecated and will be removed in an upcoming release. Use deferred.promise.then instead.
  • promise.yield(promiseOrValue) convenience API for substituting a new value into a promise chain.
  • promise.spread(variadicFunction) convenience API for spreading an array onto a fulfill handler that accepts variadic arguments. Mmmm, buttery
  • Doc improvements:
    • when() and promise.then() have more info about callbacks and chaining behavior.
    • More info and clarifications about the roles of Deferred and Resolver
    • Several minor clarifications for various APIs
  • Internal improvements to assimilation and interoperability with other promise implementations.

1.6.1

  • Fix for accidental coercion of non-promises. See #62.

1.6.0

  • New when.join - Joins 2 or more promises together into a single promise.
  • when.some and when.any now act like competitive races, and have generally more useful behavior. Read the discussion in #60.
  • Experimental progress event propagation. Progress events will propagate through promise chains. Read the details here.
  • Temporarily removed calls to Object.freeze. Promises are no longer frozen due to a horrendous v8 performance penalty. Read discussion here.
    • IMPORTANT: Continue to treat promises as if they are frozen, since freeze() will be reintroduced once v8 performance improves.
  • when/debug now allows setting global a debugging callback for rejected promises.

1.5.2

1.5.1

  • Performance optimization for when.defer, up to 1.5x in some cases.
  • when/debug can now log exceptions and rejections in deeper promise chains, in some cases, even when the promises involved aren't when.js promises.

1.5.0

  • New task execution and concurrency management: when/sequence, when/pipeline, and when/parallel.
  • Performance optimizations for when.all and when.map, up to 2x in some cases.
  • Options for disabling paranoid mode that provides a significant performance gain in v8 (e.g. Node and Chrome). See this v8 performance problem with Object.freeze for more info.
  • Important: deferred and deferred.resolver no longer throw when resolved/rejected multiple times. They will return silently as if the they had succeeded. This prevents parties to whom only the resolver has been given from using try/catch to determine the state of the associated promise.
    • For debugging, you can use the when/debug module, which will still throw when a deferred is resolved/rejected multiple times.

1.4.4

  • Change UMD boilerplate to check for exports to avoid a problem with QUnit. See #54 for more info.

1.4.3

1.4.2

  • Fix for IE8 infinite recursion (See #49)

1.4.1

  • Code and unit test cleanup and streamlining--no functional changes.

1.4.0

  • Create a resolved promise: when.resolve(value) creates a resolved promise for value. See API docs.
  • Resolve/reject return something useful: deferred.resolve and deferred.reject now return a promise for the fulfilled or rejected value.
  • Resolve a deferred with another promise: deferred.resolve(promise) - when promise resolves or rejects, so will deferred.

1.3.0

  • Fixed a deviation from the Promises/A spec where returning undefined from a callback or errback would cause the previous value to be forwarded. See #31
    • This could be a breaking change if you depended on this behavior. If you encounter problems, the solution is to ensure that your promise callbacks (registered either with when() or .then()) return what you intend, keeping in mind that not returning something is equivalent to returning undefined.
  • This change also restores compatibility with the promises returned by jQuery.get(), which seem to reject with themselves as the rejection value. See issue #41 for more information and discussion. Thanks to @KidkArolis for raising the issue.

1.2.0

  • promise.otherwise(errback) as a shortcut for promise.then(null, errback). See discussion here and here. Thanks to @jonnyreeves for suggesting the name "otherwise".
  • when/debug now detects exceptions that typically represent coding errors, such as SyntaxError, ReferenceError, etc. and propagates them to the host environment. In other words, you'll get a very loud stack trace.

1.1.1

  • Updated wiki map/reduce examples, and added simple promise forwarding example
  • Fix for calling when.any() without a callback (#33)
  • Fix version number in when.js source (#36)

1.1.0

  • when.all/any/some/map/reduce can all now accept a promise for an array in addition to an actual array as input. This allows composing functions to do interesting things like when.reduce(when.map(...))
  • when.reject(promiseOrValue) that returns a new, rejected promise.
  • promise.always(callback) as a shortcut for promise.then(callback, callback)
  • Highly experimental when/debug module: a drop-in replacement for the main when module that enables debug logging for promises created or consumed by when.js

1.0.4

  • Travis CI integration
  • Fix for cancelable deferred not invoking progress callbacks. (#24 Thanks @scothis)
  • The promise returned by when.chain now rejects when the input promise rejects.

1.0.3

  • Fix for specific situation where null could incorrectly be used as a promise resolution value (#23)

1.0.2

  • Updated README for running unit tests in both Node and Browsers. See Running the Unit Tests below.
  • Set package name to 'when' in package.json

1.0.1

  • Fix for rejections propagating in some cases when they shouldn't have been (#19)
  • Using buster.js for unit tests now.

1.0.0

  • First official when.js release as a part of cujojs.
  • Added when/cancelable decorator for creating cancelable deferreds
  • Added when/delay and when/timeout helpers for creating delayed promises and promises that timeout and reject if not resolved first.

0.11.1

  • Added when/apply helper module for using arguments-based and variadic callbacks with when.all, when.some, when.map, or any promise that resolves to an array. (#14)
  • .then(), when(), and all other methods that accept callback/errback/progress handlers will throw if you pass something that's not a function. (#15)

0.11.0

  • when.js now assimilates thenables that pass the Promises/A duck-type test, but which may not be fully Promises/A compliant, such as jQuery's Deferred and curl's global API (See the API at a glance section)
    • when(), and when.all/some/any/map/reduce/chain() are all now guaranteed to return a fully Promises/A compliant promise, even when their input is not compliant.
    • Any non-compliant thenable returned by a callback or errback will also be assimilated to protect subsequent promises and callbacks in a promise chain, and preserve Promises/A forwarding guarantees.

0.10.4

  • Important Fix for some AMD build/optimizer tools: Switching back to more verbose, builder-friendly boilerplate
    • If you are using when.js 0.10.3 with the dojo or RequireJS build tools, you should update to v.10.4 as soon as possible.

0.10.3

Warning: This version will not work with most AMD build tools. You should update to 0.10.4 as soon as possible.

  • Minor package.json updates
  • Slightly smaller module boilerplate

0.10.2

  • Performance optimizations for when.map() (thanks @smitranic), especially for large arrays where the mapFunc is also async (i.e. returns a promise)
  • when.all/some/any/map/reduce handle sparse arrays (thanks @rwaldrn)
  • Other minor performance optimizations

0.10.1

  • Minor tweaks (thanks @johan)
    • Add missing semis that WebStorm didn't catch
    • Fix DOH submodule ref, and update README with info for running unit tests

0.10.0

  • when.map and when.reduce - just like Array.map and Array.reduce, but they operate on promises and arrays of promises
  • Lots of internal size and performance optimizations
  • Still only 1k!

0.9.4

  • Important fix for break in promise chains