# fliphub-core

> the core of fliphub, an extensible hub api

Latest version **0.0.6** (published 2017-04-13) · 0 weekly downloads

## Install

```sh
npm install fliphub-core
pnpm add fliphub-core
yarn add fliphub-core
bun add fliphub-core
```

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2017-04-13 |
| First published | 2017-03-29 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 13 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 30 |
| Author | James |
| Maintainers | aretecode |
| Keywords | core, api, hubs, fliphub, flipbox |

## Links

- npm: https://www.npmjs.com/package/fliphub-core
- Repository: https://github.com/fliphub/fliphub
- Homepage: https://github.com/fliphub/fliphub#readme
- Issues: https://github.com/fliphub/fliphub/issues
- npm.io page: https://npm.io/package/fliphub-core

## Dependencies (13)

- [izz](https://npm.io/package/izz.md) *
- [fliplog](https://npm.io/package/fliplog.md) *
- [flipflag](https://npm.io/package/flipflag.md) *
- [remap-by](https://npm.io/package/remap-by.md) *
- [deepmerge](https://npm.io/package/deepmerge.md) ^1.3.2
- [flipchain](https://npm.io/package/flipchain.md) *
- [arr-to-obj](https://npm.io/package/arr-to-obj.md) *
- [deep-replace](https://npm.io/package/deep-replace.md) *
- [eventemitter2](https://npm.io/package/eventemitter2.md) ^3.0.1
- [lodash.forown](https://npm.io/package/lodash.forown.md) ^4.4.0
- [fliphub-resolve](https://npm.io/package/fliphub-resolve.md) *
- [inspector-gadget](https://npm.io/package/inspector-gadget.md) *
- [lodash.camelcase](https://npm.io/package/lodash.camelcase.md) ^4.3.0

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 0.0.6 (latest) — 2017-04-13
- 0.0.5 — 2017-04-06
- 0.0.4 — 2017-04-04
- 0.0.2 — 2017-03-29

## README

# 💠💗 fliphub-core

[![NPM version][fliphub-core-npm-image]][fliphub-core-npm-url]
[![MIT License][license-image]][license-url]
[![fliphub][gitter-badge]][gitter-url]
[![flipfam][flipfam-image]][flipfam-url]

[fliphub-core-npm-image]: https://img.shields.io/npm/v/fliphub-core.svg
[fliphub-core-npm-url]: https://npmjs.org/package/fliphub-core
[license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
[license-url]: https://spdx.org/licenses/MIT
[gitter-badge]: https://img.shields.io/gitter/room/fliphub/green.svg
[gitter-url]: https://gitter.im/fliphub/Lobby
[flipfam-image]: https://img.shields.io/badge/%F0%9F%8F%97%20%F0%9F%92%A0-flipfam-9659F7.svg
[flipfam-url]: https://www.npmjs.com/package/flipfam

> the core of fliphub, an extensible hub api for building programs with an event-based core/workflow/context/presets

## 📦 usage
```bash
yarn add fliphub-core
npm i fliphub-core --save
```

```js
const FlipHubCore = require('fliphub-core')
```


## 🏛️ paradigm

### ❔ when

there are multiple things [context](#-context), one [core](#-core), one [workflow](#-workflow) to connect them, and reusable configurations that optionally can be inherited

### ❔ why

creating a program which has a core that is as minimal as possible
as much functionality is added via presets as possible

in turn, a phenomenal external api is created, since you use it to build your program.

this allows extremely easy maintenance and extension because





## 💗 core
- extends [flipchain/ChainedMapExtendable](https://www.npmjs.com/package/flipchain)
- your core program
- one core for every system
- every core has a core config
- high level





## 💮 workflow
- extends [flipchain/ChainedMapExtendable](https://www.npmjs.com/package/flipchain)
- connecting the core-hubs-context
- is passed into each lifecycle event to use one object to access the whole program easily




## ✳️ context
- extends [flipchain/ChainedMapExtendable](https://www.npmjs.com/package/flipchain)

## ⚙ configs
- options/config/opts/prefs/settings/args
- 🍉 rehydratable
- ⛓ chainable / fluent

#### 💗⚙ coreConfig
- user settings for your core, inheritable if `inherit` is not false

#### 💮⚙ contextContext
- configs per context, each context can have multiple configs if hubs extend, but it is usually just one


## 💠 hub

- is essentially [middleware][middleware-pattern], but a shorter name, and can do
- [decorators][decorator-pattern]
- [middleware][middleware-pattern]

[middleware-pattern]: https://en.wikipedia.org/wiki/Interceptor_pattern
[decorator-pattern]: https://sourcemaking.com/design_patterns/decorator




## 🍰 presets
- combinations of hubs, or/and configurations.


## 👂 events & 📚 docs
[🔗 events & docs](https://github.com/fliphub/fliphub/blob/master/modules/fliphub-core/readme-docs.md)





## 📘 examples


#### emitting
```js
// emits for core
this.workflow.evt.name('name-of-event-scoped-to->').core().emit(data)

// subscribe to a core event
this.workflow.evt.core().name('eh').cb(this.cb)

// emits for a single context
this.workflow.evt.name('name-of-event-scoped-to->').context('name').emit(data)

// emits for * contexts
this.workflow.evt.name('name-of-event-scoped-to->').contexts().emit(data)
```


## example (fliphub)
```js
workflow.contextsFrom(config.apps)
workflow.emitForContexts('merge.pre')
workflow.emitForContexts('init.pre')
workflow.emitForContexts('init')
workflow.emitForContexts('init.post')
workflow.emitForContexts('merge.post')
workflow.mapContexts((context) => {
  // edit context
  return context
})
```



### ☕💠 filterhub
- built in filtering for filtering contexts by calling the functions



### exports / extending

```js

// export as named, and as abstract for destructuring support
const {
  log,
  resolve,

  Core,
  AbstractCore,

  Context,
  AbstractContext,

  Workflow,
  AbstractWorkflow,

  Hub,
  AbstractHub,

  Presets,
  AbstractPresets,

  ChainedMap,
} = require('fliphub-core')
```







### 📦 deps
- [flipchain][deps-flipchain] for a powerful fluent chainable api
- [eventemitter2][deps-eventemitter2] in [Event][src-core-event] for fast event emitting lifecycle
- [fliplog][deps-fliplog] + [inspector-gadget][deps-inspector-gadget] for debugging

<!--
remap-by
arr-to-obj
deepmerge
deep-replace
lodash.camelcase
izz
lodash.forown
-->

# schema
- [core] 1 - 1 [workflow]
- [core] 1 - 1 [config]
- [workflow] 1 - * [hub]
- [workflow] 1 - * [context]
- [context] 1 - * [config]



[src-core-event]: https://github.com/fliphub/fliphub/blob/master/modules/fliphub-core/Events.js
[deps-eventemitter2]: https://github.com/asyncly/EventEmitter2
[deps-flipchain]: https://www.npmjs.com/package/flipchain
[deps-fliplog]: https://www.npmjs.com/package/fliplog
[deps-inspector-gadget]: https://www.npmjs.com/package/inspector-gadget

---
_Source: https://npm.io/package/fliphub-core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
