Minimalist alternative for Base. Build complex APIs with small units called plugins. Works well with most of the already existing base plugins.
You might also be interested in base.
Table of Contents
(TOC generated by verb using markdown-toc)
Install
Install with npm
$ npm install minibase --save
or install using yarn
$ yarn add minibase
Usage
For more use-cases see the tests
const minibase =
API
MiniBase
Creates an instance of
MiniBase
with optionaloptions
object - if given, otherwise theminibase.options
defaults to empty object. Never throws - emit events!™
Params
[options]
{Object}: optional, written tothis.options
Example
const MiniBase = MiniBase // main export is instanceconst app = app app app
.delegate
Copy properties from
provider
tothis
instance ofMiniBase
, using delegate-properties lib.
Params
<provider>
{Object}: object providing propertiesreturns
{Object}: Returns instance for chaining
Example
const minibase = minibase // or directly use `.delegate`,// not through pluginminibase console // => 'dogs'console // => 'bar'console // => 'hello kitty!'
.define
Used for adding non-enumerable property
key
withvalue
on the instance, using define-property lib.
Params
key
{String}: name of the property to be defined or modifiedvalue
{any}: descriptor for the property being defined or modifiedreturns
{Object}: Returns instance for chaining
Example
const minibase = minibase minibase // or directly use `.define`,// not through pluginminibaseconsole // => 'kitty' console // => 'bar'console // => 123console // => { a: 'b' } // or access the cache directlyconsole // => { a: 'b' }console // => 123
.use
Define a synchronous plugin
fn
function to be called immediately upon init. Never throws - emit events!™
Params
fn
{Function}: plugin passed withctx
which is the instancereturns
{Object}: Returns instance for chaining
Events
emits
:error
when pluginfn
throws an error
Example
const MiniBase = MiniBaseconst app = app
#delegate
Static method to delegate properties from
provider
toreceiver
and make them non-enumerable.
See delegate-properties for more details, it is exact mirror.
Params
receiver
{Object}: object receiving propertiesprovider
{Object}: object providing properties
Example
const MiniBase = MiniBase const obj = foo: 'bar' MiniBase console // => 'bar'console // => 123
#define
Static method to define a non-enumerable property on an object.
See define-property for more details, it is exact mirror.
Params
obj
{Object}: The object on which to define the propertyprop
{Object}: The name of the property to be defined or modifieddescriptor
{any}: The descriptor for the property being defined or modified
Example
const MiniBase = MiniBase const obj = {}MiniBaseMiniBase console // => 123console // => 'qux'
#extend
Static method for inheriting the prototype and static methods of the
MiniBase
class. This method greatly simplifies the process of creating inheritance-based applications.
See static-extend for more details.
Params
Ctor
{Function}: constructor to extendmethods
{Object}: optional prototype properties to mix in
Example
const MiniBase = MiniBase { MiniBase} MiniBase console // => functionconsole // => functionconsole // => function const app = console // => functionconsole // => functionconsole // => function
Related
- base: base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting with a handful of common… more | homepage
- generate: Command line tool and developer framework for scaffolding out new GitHub projects. Generate offers the robustness and configurability of Yeoman… more | homepage
- lazy-cache: Cache requires to be lazy-loaded when needed. | homepage
- minibase-better-define: Plugin for base and minibase that overrides the core
.define
method to be more better. | homepage - minibase-create-plugin: Utility for minibase and base that helps you create plugins | homepage
- minibase-is-registered: Plugin for minibase and base, that adds
isRegistered
method to your application to detect if plugin is already registered and… more | homepage - minibase-visit: Plugin for minibase and base, that adds
.visit
method to your application to visit a method over the items in… more | homepage - try-catch-callback: try/catch block with a callback, used in try-catch-core. Use it when you don't care about asyncness so much and don't… more | homepage
- use: Easily add plugin support to your node.js application. | homepage
- verb: Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used on hundreds of projects of… more | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Please read the contributing guidelines for advice on opening issues, pull requests, and coding standards.
If you need some help and can spent some cash, feel free to contact me at CodeMentor.io too.
In short: If you want to contribute to that project, please follow these things
- Please DO NOT edit README.md, CHANGELOG.md and .verb.md files. See "Building docs" section.
- Ensure anything is okey by installing the dependencies and run the tests. See "Running tests" section.
- Always use
npm run commit
to commit changes instead ofgit commit
, because it is interactive and user-friendly. It uses commitizen behind the scenes, which follows Conventional Changelog idealogy. - Do NOT bump the version in package.json. For that we use
npm run release
, which is standard-version and follows Conventional Changelog idealogy.
Thanks a lot! :)
Building docs
Documentation and that readme is generated using verb-generate-readme, which is a verb generator, so you need to install both of them and then run verb
command like that
$ npm install verbose/verb#dev verb-generate-readme --global && verb
Please don't edit the README directly. Any changes to the readme must be made in .verb.md.
Running tests
Clone repository and run the following in that cloned directory
$ npm install && npm test
Author
Charlike Mike Reagent
License
Copyright © 2016, Charlike Mike Reagent. Released under the MIT license.
This file was generated by verb-generate-readme, v0.2.0, on December 05, 2016.