https://github.com/bowheart/sheath-core
The Module Library
https://github.com/bowheart/sheath-core
async dependency-injection module-loader modules
Last synced: 8 months ago
JSON representation
The Module Library
- Host: GitHub
- URL: https://github.com/bowheart/sheath-core
- Owner: bowheart
- License: mit
- Created: 2016-09-17T16:39:48.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-07T13:56:38.000Z (almost 9 years ago)
- Last Synced: 2025-01-22T18:34:02.288Z (about 1 year ago)
- Topics: async, dependency-injection, module-loader, modules
- Language: JavaScript
- Homepage:
- Size: 114 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/bowheart/sheath-core)
[](https://codeclimate.com/github/bowheart/sheath-core/coverage)
[](https://codeclimate.com/github/bowheart/sheath-core/issues)
[](https://codeclimate.com/github/bowheart/sheath-core)
# Sheath
Sheath is a utility library for modular applications. It's *the* module library.
Check out Sheath's coolness list:
- A clean, overly simplistic interface for creating modules.
- Dependency injection.
- Asynchronous script loading.
- Utilities for easily creating common types of modules.
- Designed to improve the flow of frameworks such as Backbone, React, Inferno, and Mithril.
- Awesome debugging tools, including opt-in circular dependency detection.
- Even awesomer dependency graph analysis tools available server-side for easy automation.
- Highly optimized code. Most of Sheath's algorithms are simple lookups – O(1) time.
## A simple example
> Note: All examples will use es6 syntax. You've been warned.
Let's create a module.
```javascript
sheath('dagger', () => 'a dagger')
```
Simple as that. Let's break down what happened here:
- We *declared* a module named 'dagger'.
- Sheath called our arrow function. This function is our module's *factory*. The factory *defined* our module.
- We exposed the string `'a dagger'` as our module's *default export*. Our module's exports are what will get injected into dependents.
Alright. Cool, I guess. Now what was the point of that?
Let's create another module:
```javascript
sheath('assassin', ['dagger'], dagger =>
'A deadly assassin. Weapon: ' + dagger
)
```
Let's break this one down:
- We declared a module named 'assassin' with one dependency, 'dagger'.
- Sheath ensured that the dagger module was loaded before:
- Sheath called the assassin module's factory, passing ("injecting") the dagger module's default export as the first argument. This defined the assassin module.
- We exposed a new string as the default export of the assassin module.
Every module goes through this basic life cycle.
## To Be Continued...
That's really all you need to get started! Take a look at the [github wiki](https://github.com/bowheart/sheath-core/wiki) for a more in-depth rundown and the full API documentation.
## Bugs, Pull Requests, Feedback, Just Everything
Bugs can be reported at the [github issues page](https://github.com/bowheart/sheath-core/issues). All suggestions and feedback are so super welcome. Also feel free to fork and pull request – just make sure the tests pass (`npm test`) and try to keep the tests at ~100% coverage. Happy coding!
## License
The [MIT License](LICENSE)