# @statusbar/block

> Create blocks for Statusbar.

Latest version **0.0.2** (published 2017-03-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install @statusbar/block
pnpm add @statusbar/block
yarn add @statusbar/block
bun add @statusbar/block
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2017-03-13 |
| First published | 2017-03-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Renée Kooi |
| Maintainers | goto-bus-stop, statusbar |

## Links

- npm: https://www.npmjs.com/package/@statusbar/block
- Repository: https://github.com/goto-bus-stop/statusbar
- Homepage: https://github.com/goto-bus-stop/statusbar#readme
- Issues: https://github.com/goto-bus-stop/statusbar/issues
- npm.io page: https://npm.io/package/@statusbar/block

## Recent versions

- 0.0.2 (latest) — 2017-03-13
- 0.0.1 — 2017-03-06

## README

# @statusbar/block

Create blocks for [Statusbar](https://github.com/goto-bus-stop/statusbar).

## Usage

```js
// date.js
const block = require('@statusbar/block')

module.exports = block({
  // A unique name for your block.
  name: 'date',

  // Default options.
  options: {
    format: 'YYYY-MM-DD HH:mm:ss'
  },

  // If you provide a function instead, its return value is used as the options
  // instead. This way you can accept non-object values as options:
  options (options) {
    // dateBlock('MM-DD-YYYY HH:mm')
    if (typeof options === 'string') {
      return { format: options }
    }
    // Provide defaults.
    return Object.assign({
      format: 'YYYY-MM-DD HH:mm:ss',
    }, options)
  },

  // If your block needs to update every N seconds, you can provide an interval.
  // This will keep calling your `run` method.
  // Numeric value in milliseconds.
  interval: 1000,

  // If you need to do some initialisation, do it in the `init` method.
  // First argument is the Block, second is the provided options.
  init (b, options) {
  },

  // Run your block.
  // First argument is the Block, second is the provided options.
  run (b, options) {
    b.update(format(new Date(), options.format))
  },

  // Clean up when the status bar is shutting down.
  // First argument is the Block, second is the provided options.
  dispose (b, options) {
  }
})
```

Now, this block can be used as:

```js
const date = require('./date.js')
bar.use(date())
// or
bar.use(date({ interval: 2000 }))
// or
bar.use(date('MM-DD-YYYY HH:mm'))
```

## License

[MIT](../../LICENSE)

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