https://github.com/miguelcastillo/bit-bundler-utils
nodejs helpers for bit-bundler and bit-imports
https://github.com/miguelcastillo/bit-bundler-utils
Last synced: about 2 months ago
JSON representation
nodejs helpers for bit-bundler and bit-imports
- Host: GitHub
- URL: https://github.com/miguelcastillo/bit-bundler-utils
- Owner: MiguelCastillo
- Created: 2016-01-03T19:09:09.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-04-22T23:02:04.000Z (about 5 years ago)
- Last Synced: 2025-03-17T20:41:27.706Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 94.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# bit-bundler-utils
[](https://greenkeeper.io/)
nodejs helpers for bit-bundler and bit-imports
### uniqueId.getId
Method that generates numeric ids from module ids, which are the full path for the module on storage.- @param {string} moduleId - module id generated by bit-loader to convert to module id consumed by bit-bundler.
- @returns {int} module id to be consumed by bit-bundler.
> uniqueId.getId will cache the results it produces so that subsequent calls with the same input generates the exact same output.
### uniqueId.setId
Method to set an id, that is treated as unique. It can only be set to one value... If an attempt to set it the id to a different value once it is set, an exception is raised.- @param {string} moduleId - module id generated by bit-loader.
- @param {string} value - unique value to be mapped to the module id.> uniqueId.setId can be called multiple times with the same value successfully.
### resolvePath
Helper method for resolving module names and relative paths to full absolute paths. `resolvePath` uses [browser-resolve](https://github.com/defunctzombie/node-browser-resolve) for node.js module resolution.- @param {{ string: name }} input - Object with the property `name` of the module to be resolved.
- @param {object} browserResolveOptions - Options to be forwarded to browser-resolve. `baseUrl` defaults to `process.cwd()`.- @returns {Promise} Promise that when resolved it returns an object with a property `path` for the module.
``` javascript
var resolver = require("bit-bundler-utils/resolvePath");resolver({
name: "jquery"
})
.then(function(result) {
console.log(result.path);
return result;
});
```### readFile
Helper method to read files from disk. This method returns promises that when resolved it returns the content of the file. *readFile gracefully handles binary files*.- @param {{ string: path }} input - Object with property `path` for the file to be loaded from disk.
- @returns {Promise} That when resolved, returns and object with a string property containing the file content#### Example
``` javascript
var readFile = require("bit-bundler-utils/readFile");readFile({
path: "./file/path"
})
.then(function(result) {
console.log(result.source);
return result;
});
```License
===============Licensed under MIT