Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qfox/pym
:gift: Packaged YM-modules
https://github.com/qfox/pym
Last synced: 23 days ago
JSON representation
:gift: Packaged YM-modules
- Host: GitHub
- URL: https://github.com/qfox/pym
- Owner: qfox
- License: mit
- Created: 2014-09-10T17:42:27.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-10-03T20:20:07.000Z (about 8 years ago)
- Last Synced: 2024-09-15T04:07:40.465Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 25.4 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pym
[![NPM version](https://img.shields.io/npm/v/pym.svg?style=flat)](https://www.npmjs.org/package/pym)
[![Build Status](https://img.shields.io/travis/zxqfox/pym.svg?branch=master&style=flat)](https://travis-ci.org/zxqfox/pym)
[![Coverage Status](https://img.shields.io/coveralls/zxqfox/pym.svg?style=flat)](https://coveralls.io/r/zxqfox/pym?branch=master)
[![Dependency Status](https://img.shields.io/david/zxqfox/pym.svg?style=flat)](https://david-dm.org/zxqfox/pym)
[![Dev Dependency Status](https://img.shields.io/david/dev/zxqfox/pym.svg?style=flat)](https://david-dm.org/zxqfox/pym)Packaged YM-modules
## What is it?
It's a CommonJS module-assistant for creating plugin-based apps.
Provides API for loading packages (plugins as npm-modules).
Supports asynchronous `define`, `require`, `provide` (inherited from `ym`).
Made for simplifying plugin-based apps building.
Why it's not based on `CommonJS`? Because `ym` is more elegant.
## API
Пакет предоставляет класс `App`, от которого можно наследовать класс вашего приложения; а так же статический метод `create`.
### App
```js
var pym = require('pym');
var util = require('util');util.inherits(myApp, pym);
function myApp(opts) {
pym.call(this, opts);
// your custom application
}var app = new myApp();
```### App.create
```js
var app = require('pym').create({ /* options */ });
```### App.prototype.define - module definition
- {string} moduleName
- {string[]} [dependencies]
- {function(function(objectToProvide, [error]), ...[resolvedDependency], [previousDeclaration])} declarationFunctionsee [ym.prototype.define](https://github.com/ymaps/modules/#module-declaration)
### App.prototype.require - module usage
- {string[]} dependencies
- {function(...[resolvedDependency])} successCallbackFunction
- {function(error: Error)} [errorCallbackFunction]see [ym.prototype.require](https://github.com/ymaps/modules/#module-usage)
### App.prototype.usePackage - package loading
Waits for:
- {String} package — npm-package name or path to package
- {Object} options — some package options```js
var app = require('pym').create({ /* options */ });
app.usePackage('some-npm-package');
app.require('module', function (module) {
// your app
module.doSomething();
});
```## Relation to Architect
`pym` has a wrapper to load modules built with [Architect plugin interface](https://github.com/c9/architect/#plugin-interface).
It means you can easily use packages (plugins) made for `Architect` platform in `pym` infrastructure. `Architect` services will be resolved as `ym`-modules.Differences from `Architect`:
- it hasn't `loadConfig` method — and no frozen config format, use any config you like;
- it supports asynchronous provide in runtime;
- packages interface is more explicit.## Thanks
- Built with [ymaps/modules](https://github.com/ymaps/modules)
- Inspired by [c9/architect](https://github.com/c9/architect)## License
[MIT](http://github.com/zxqfox/pym/blob/master/LICENSE)