CommonJS Utils is a collection of various CommonJS modules. Modules include:
This module returns a factory for creating custom Error constructors. The extend-error export is a function:
ErrorConstructor(name, superError) - Creates a new error constructor. For example:
MyError = require("commonjs-utils/extend-error")("MyError", Error); ... throw new MyError("something went wrong");
- parse(str) - Parse the provided JSON-style object, array, or primitive literal string.
- stringify(value) - Encodes the provided value as a JSON-style object, array, or primitive literal.
- encode(str) - Encode the provided string in base64
- decode(base64) - Decode a base64 string to a normal string
More extensive information on CommonJS utilities can be found here:
CommonJS Utils is part of the Persevere project, and therefore is licensed under the AFL or BSD license. The Persevere project is administered under the Dojo foundation, and all contributions require a Dojo CLA.