plugins 0.4.2 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -230
- package/dist/index.js +946 -0
- package/package.json +11 -40
- package/LICENSE +0 -24
- package/index.js +0 -119
- package/iterators.js +0 -102
package/README.md
CHANGED
|
@@ -1,237 +1,17 @@
|
|
|
1
|
-
# plugins
|
|
1
|
+
# plugins
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Install open-plugin format plugins into agent tools.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Usage
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
```sh
|
|
10
|
-
$ npm i plugins --save
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
See [the examples](examples/).
|
|
14
|
-
|
|
15
|
-
## Table of contents
|
|
16
|
-
|
|
17
|
-
<!-- toc -->
|
|
18
|
-
|
|
19
|
-
* [Docs](#docs)
|
|
20
|
-
* [Creating plugins](#creating-plugins)
|
|
21
|
-
- [sync](#sync)
|
|
22
|
-
- [async](#async)
|
|
23
|
-
- [Directly run plugins](#directly-run-plugins)
|
|
24
|
-
* [API](#api)
|
|
25
|
-
* [Related projects](#related-projects)
|
|
26
|
-
* [Running tests](#running-tests)
|
|
27
|
-
* [Contributing](#contributing)
|
|
28
|
-
* [Author](#author)
|
|
29
|
-
* [License](#license)
|
|
30
|
-
|
|
31
|
-
_(Table of contents generated by [verb])_
|
|
32
|
-
|
|
33
|
-
<!-- tocstop -->
|
|
34
|
-
|
|
35
|
-
## Docs
|
|
36
|
-
|
|
37
|
-
See [the examples](examples/).
|
|
38
|
-
|
|
39
|
-
## Creating plugins
|
|
40
|
-
|
|
41
|
-
> A plugin can take any arguments and **must return a function**.
|
|
42
|
-
|
|
43
|
-
### sync
|
|
44
|
-
|
|
45
|
-
Plugins just return a value.
|
|
46
|
-
|
|
47
|
-
**Example:**
|
|
48
|
-
|
|
49
|
-
```js
|
|
50
|
-
var plugins = new Plugins();
|
|
51
|
-
|
|
52
|
-
plugins
|
|
53
|
-
.use(function (str) {
|
|
54
|
-
return str + 'a';
|
|
55
|
-
})
|
|
56
|
-
.use(function (str) {
|
|
57
|
-
return str + 'b';
|
|
58
|
-
})
|
|
59
|
-
.use(function (str) {
|
|
60
|
-
return str + 'c';
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
console.log(plugins.run('alphabet-'));
|
|
64
|
-
//=> 'alphabet-abc'
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### async
|
|
68
|
-
|
|
69
|
-
Pass `next` as the last argument to run plugins asynchronously.
|
|
70
|
-
|
|
71
|
-
**Example:**
|
|
72
|
-
|
|
73
|
-
```js
|
|
74
|
-
var plugins = new Plugins();
|
|
75
|
-
|
|
76
|
-
plugins
|
|
77
|
-
.use(function (str, next) {
|
|
78
|
-
next(null, str + 'a');
|
|
79
|
-
})
|
|
80
|
-
.use(function (str, next) {
|
|
81
|
-
next(null, str + 'b');
|
|
82
|
-
})
|
|
83
|
-
.use(function (str, next) {
|
|
84
|
-
next(null, str + 'c');
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
plugins.run('alphabet-', function (err, str) {
|
|
88
|
-
console.log(str); //=> 'alphabet-abc'
|
|
89
|
-
});
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Directly run plugins
|
|
93
|
-
|
|
94
|
-
To run plugins **without** `.use()`, pass an array of functions as a section argument to `.run()`.
|
|
95
|
-
|
|
96
|
-
**sync example:**
|
|
97
|
-
|
|
98
|
-
```js
|
|
99
|
-
var plugins = new Plugins();
|
|
100
|
-
|
|
101
|
-
var a = function(val) {
|
|
102
|
-
return val + 'a';
|
|
103
|
-
};
|
|
104
|
-
var b = function(val) {
|
|
105
|
-
return val + 'b';
|
|
106
|
-
};
|
|
107
|
-
var c = function(val) {
|
|
108
|
-
return val + 'c';
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
console.log(plugins.run('alphabet-', [a, b, c]));
|
|
112
|
-
//=> 'alphabet-abc'
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
**async example:**
|
|
116
|
-
|
|
117
|
-
```js
|
|
118
|
-
var plugins = new Plugins();
|
|
119
|
-
|
|
120
|
-
var a = function (str, next) {
|
|
121
|
-
next(null, str + 'a');
|
|
122
|
-
};
|
|
123
|
-
var b = function (str, next) {
|
|
124
|
-
next(null, str + 'b');
|
|
125
|
-
};
|
|
126
|
-
var c = function (str, next) {
|
|
127
|
-
next(null, str + 'c');
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
plugins.run('alphabet-', [a, b, c], function (err, str) {
|
|
131
|
-
console.log(str); //=> 'alphabet-abc'
|
|
132
|
-
});
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
## API
|
|
136
|
-
|
|
137
|
-
See [the examples](examples/).
|
|
138
|
-
|
|
139
|
-
### [Plugins](index.js#L23)
|
|
140
|
-
|
|
141
|
-
Initialize `Plugins`
|
|
142
|
-
|
|
143
|
-
**Example**
|
|
144
|
-
|
|
145
|
-
```js
|
|
146
|
-
var Plugins = require('plugins');
|
|
147
|
-
var plugins = new Plugins();
|
|
7
|
+
```bash
|
|
8
|
+
npx plugins add <repo-path-or-url>
|
|
148
9
|
```
|
|
149
10
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
Add a plugin `fn` to the `plugins` stack.
|
|
153
|
-
|
|
154
|
-
**Params**
|
|
155
|
-
|
|
156
|
-
* `fn` **{Function}**: Plugin function to add to the `plugins` stack.
|
|
157
|
-
* `returns` **{Object}** `Plugins`: to enable chaining.
|
|
11
|
+
## Development
|
|
158
12
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
.use(foo)
|
|
164
|
-
.use(bar)
|
|
165
|
-
.use(baz)
|
|
13
|
+
```bash
|
|
14
|
+
npm install
|
|
15
|
+
npm run build
|
|
16
|
+
node dist/index.js --help
|
|
166
17
|
```
|
|
167
|
-
|
|
168
|
-
### [.run](index.js#L73)
|
|
169
|
-
|
|
170
|
-
Call each `fn` in the `plugins` stack to iterate over `val`.
|
|
171
|
-
|
|
172
|
-
**Params**
|
|
173
|
-
|
|
174
|
-
* `val` **{Array|Object|String}**: The value to iterate over.
|
|
175
|
-
|
|
176
|
-
**Example**
|
|
177
|
-
|
|
178
|
-
```js
|
|
179
|
-
plugins.run(value)
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
### [.iterator](index.js#L87)
|
|
183
|
-
|
|
184
|
-
Register an iterator `fn` by its `type`.
|
|
185
|
-
|
|
186
|
-
**Params**
|
|
187
|
-
|
|
188
|
-
* `type` **{String}**: The iterator type.
|
|
189
|
-
* `fn` **{Function}**: Iterator function
|
|
190
|
-
|
|
191
|
-
### [.pipeline](index.js#L103)
|
|
192
|
-
|
|
193
|
-
Add each plugin to a pipeline to be used with streams. Plugins must either be a stream or a function that returns a stream.
|
|
194
|
-
|
|
195
|
-
**Params**
|
|
196
|
-
|
|
197
|
-
* `val` **{Array|Object|String}**: The value to iterate over.
|
|
198
|
-
|
|
199
|
-
**Example**
|
|
200
|
-
|
|
201
|
-
```js
|
|
202
|
-
var pipeline = plugins.pipeline(plugin());
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
## Related projects
|
|
206
|
-
|
|
207
|
-
[async-array-reduce](https://github.com/jonschlinkert/async-array-reduce): Async reduce.
|
|
208
|
-
|
|
209
|
-
## Running tests
|
|
210
|
-
|
|
211
|
-
Install dev dependencies:
|
|
212
|
-
|
|
213
|
-
```sh
|
|
214
|
-
$ npm i -d && npm test
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
## Contributing
|
|
218
|
-
|
|
219
|
-
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/plugins/issues/new)
|
|
220
|
-
|
|
221
|
-
## Author
|
|
222
|
-
|
|
223
|
-
**Jon Schlinkert**
|
|
224
|
-
|
|
225
|
-
+ [github/jonschlinkert](https://github.com/jonschlinkert)
|
|
226
|
-
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
|
|
227
|
-
|
|
228
|
-
## License
|
|
229
|
-
|
|
230
|
-
Copyright © 2015 Jon Schlinkert
|
|
231
|
-
Released under the MIT license.
|
|
232
|
-
|
|
233
|
-
***
|
|
234
|
-
|
|
235
|
-
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 14, 2015._
|
|
236
|
-
|
|
237
|
-
[verb]: https://github.com/assemble/verb
|