2.0.0 • Published 9 years ago
webpack-super v2.0.0
webpack-super
a functional approach to writing webpack configs
Installation
npm install webpack-super --saveFunctions
- appendAt(path, value, obj) ⇒ object
- compose(...funcs) ⇒ function
- copy(path, source, destination) ⇒ object
- setAt(path, value, obj) ⇒ object
- when(condition, func) ⇒ function
appendAt(path, value, obj) ⇒ object
Creates a new object with the value set at the path provided and copy the rest.
Kind: global function
Implements: Transformer
| Param | Type | Description |
|---|---|---|
| path | string | path string where the value needs to be set |
| value | any | the value that needs to be set |
| obj | object | the object that needs to be transformed |
compose(...funcs) ⇒ function
Creates a composition factory functions
Kind: global function
Implements: Helper
| Param | Type | Description |
|---|---|---|
| ...funcs | function | factory functions |
copy(path, source, destination) ⇒ object
Copies a value at a path from source to destination
Kind: global function
Implements: Transformer
| Param | Type | Description |
|---|---|---|
| path | string | path string where the value needs to be picked/set |
| source | object | source object from where the value needs to be picked |
| destination | object | destination object where the value needs to be set |
Example
copy('a.b', {a: {b: 100}}, {p: 100}) // outputs: {a: {b: 100}, q: 100}setAt(path, value, obj) ⇒ object
Creates a new object with the value set at the path provided and copy the rest.
Kind: global function
Implements: Transformer
Returns: object - the new object with the value
| Param | Type | Description |
|---|---|---|
| path | string | path string where the value needs to be set |
| value | any | the value that needs to be set |
| obj | object | the object that needs to be transformed |
Example
setAt('entry', './src/main.js', {}) // outputs: {entry: './src/main.js'}
setAt('output.filename', '[hash].bundle.js', {}) // outputs: {output: {filename: '[hash].bundle.js'}}when(condition, func) ⇒ function
Returns a new function that is either has no effect (identity) or
or has the same as the passed func based on the condition.
Kind: global function
Implements: Transformer
| Param | Type | Description |
|---|---|---|
| condition | boolean | the condition |
| func | function | the function to be called |