# bitbar-js

> BitBar Javascript App Helper

Latest version **1.0.1** (published 2020-03-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install bitbar-js
pnpm add bitbar-js
yarn add bitbar-js
bun add bitbar-js
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2020-03-21 |
| First published | 2020-03-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | yukapril |
| Maintainers | yukapril |
| Keywords | bitbar, bitbar-js, bit, bar, app |

## Links

- npm: https://www.npmjs.com/package/bitbar-js
- Repository: https://github.com/yukapril/bitbar-js
- Homepage: https://github.com/yukapril/bitbar-js#readme
- Issues: https://github.com/yukapril/bitbar-js/issues
- npm.io page: https://npm.io/package/bitbar-js

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2020-03-21

## README

# bitbar-js

一个 BitBar js 脚本辅助工具。

灵感来源于 [sindresorhus/bitbar](https://github.com/sindresorhus/bitbar)

Inspired by [sindresorhus/bitbar](https://github.com/sindresorhus/bitbar)

## 使用方法

在 BitBar 的插件目录，首先安装依赖

```bash
npm install bitbar-js
```

之后可以编写你的模块了，比如建立文件 `test.1d.js`：

```js
#!/usr/bin/env /usr/local/bin/node
const bitbar = require('bitbar-js');

bitbar([
  {
    text: '❤',
    color: 'red',
    dropdown: false
  }
])
```

## API

### bitbar(items, options?) 或 bitbar.create(items, options?)

**配置每个栏目item的例子**

```js
// 一个简单的例子
{
  text: '❤',
  color: 'red'
}

// 带有子栏目的例子
{
  text: 'AA',
  color: 'red',
  submenu: [
    {
      text: 'AA-1',
      color: 'blue'
    },
    'AA-2' // 对于只有 text 的情况，可以简写为字符串形式
  ]
}
```

`text` 为显示的内容，`submenu` 为子栏目。其它选项，参考 [BitBar-Plugin-API](https://github.com/matryer/bitbar#plugin-api)。

#### options

如果每个栏目都有相同的配置，可以直接配置到 `options` 上。例如：

```js
bitbar([
  { 
    text: 'AA',
  },
  {
    text: 'BB',
  },
  {
    text: 'CC',
    color: 'blue',
  }
], {color: 'red'})
```

等同于：

```js
bitbar([
  {
    text: 'AA',
    color: 'red',
  },
  {
    text: 'BB',
    color: 'red',
  },
  {
    text: 'CC',
    color: 'blue',
  }
])
```

### bitbar.separator

分隔符，也可以用字符串 `---` 代替。

### bitbar.darkMode

是否为深色模式。


## 已知问题

1. 内容中含有引号 `"` `'`，我也不知道如何处理。[sindresorhus/bitbar](https://github.com/sindresorhus/bitbar) 对 URL 进行了转义。

## 错误码

| 错误码  | 原因  |
|---|---|
| 1001  | 栏目item类型错误，每行数据支持 string / object |
| 1002  | 栏目item缺少字段，需要提供 `text` 字段 |
| 1003  | 栏目item中，字段的值类型错误，支持 string/number/boolean |

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