fluent-interface-example
v1.0.4
Published
A fluent interface, with unit conversions as the example.
Downloads
8
Readme
Fluent Interface Example
A fluent interface is a form of an API that allows chaining methods to simplify common activities, especially where multiple operations are executed or options are specified in series.
Ideally fluent interfaces should only be employed where readability is improved when the API is frequently leveraged as a series of combined actions.
Common examples of Fluent Interfaces are:
jQuery
$('.mySelector')
.hide()
.addClass('anotherClass')
.show();
Request
request
.get('http://google.com/img.png')
.on('response', function(response) {
console.log(response.statusCode) // 200
console.log(response.headers['content-type']) // 'image/png'
})
.pipe(request.put('http://mysite.com/img.png'))
Installation
# npm install -g fluent-interface-example
Usage
Follow installation instructions above to install the unit-convert tool globally.
Convert millimetres to feet
# unit-convert --convert 100 --from mm --to ft
Convert celsius to fahrenheit
# unit-convert --convert 100 --from C --to F
Show all possible conversion units
# unit-convert --possibilities
Show all possible conversion units from a particular unit
# unit-convert --possibilities --from C
Running tests
# npm run test
Releasing
This repository leverages git-flow (AVH) for its branding and merging strategy. Releasing is automated via the
generate-release
tool.
Update patch version:
# npm run patch
Update minor version:
# npm run release