@fleetbase/ember-accounting

中文文档
0.0.1发布于 2023/12/20MIT近 30 天下载 4111

Updated port of the great accounting.js library to ES6 modules that integrates seamlessly with ember-cli

原始使用文档
文档目录8 节
  1. Installation
  2. Ember compatiblity
  3. Usage
  4. Accounting functions
  5. Handlebars helpers
  6. Config default options
  7. Differences with accounting.js
  8. Documentation

@fleetbase/ember-accounting

This is a fork of ember-cli-accounting which was a port of the great accounting.js library to ES6 modules that integrates seamlessly with ember-cli and the Fleetbase ecosystem.

Installation

Just add like any other ember-cli addon:

npm install @fleetbase/ember-accounting

Ember compatiblity

Compatible with Ember version 4.0 and above

Usage

Accounting functions

You no longer need to access the global accounting, you can import only what you need:

import formatMoney from '@fleetbase/ember-accounting/format-money'

Although you can import everything as expected:

import accounting from '@fleetbase/ember-accounting'

Handlebars helpers

This addon also registers 2 handy helpers in your application: format-number and format-money.

You can set options using bound or unbound options like this:

{{format-money price symbol=selectedCurrency format="%v %s"}} <!-- "123.45 £" -->

Any option not set will have the usual default value:

{{format-number "1234.567" precision=2}} <!-- "1,234.57" -->

Config default options

You can use an initializer to set some default values at initializations and avoid having to repeat over and over the options in the helpers.

Use something like this:

// app/initializers/accounting.js
import { currency, number } from '@fleetbase/ember-accounting/settings';

export default {
  name: 'accounting.js',
  initialize: function() {
    currency.symbol = "€";
    number.decimal = ",";
    number.thousand = ".";
  }
};

Differences with accounting.js

Although this is almost a 1:1 port of accountant.js, there is a few differences:

  • Each function of accountant.js lives in its own module, so you can only import those functions you want to use.
  • Removed some polyfills for Array.isArray, Array.prototype.map and Object.prototype.toString. They are not required in modern browsers, and ember.js (unless you opt-out with EXTEND_PROTOTYPES = false) already provides polyfills for those functions.
  • More tests than the original.
  • Enforced jshint. Cleaner code.

Documentation

This library does not make any change in the public api of accounting.js, so you can read the official documentation here

版本与发布记录

@fleetbase/ember-accounting 共发布 1 个版本,首次发布于 2023/12/20;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.0.1latest2023/12/202 年前

关于 @fleetbase/ember-accounting 的常见问题

@fleetbase/ember-accounting 是什么?

Updated port of the great accounting.js library to ES6 modules that integrates seamlessly with ember-cli

如何安装 @fleetbase/ember-accounting?

在项目目录运行 npm install @fleetbase/ember-accounting,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:ember-source(>= 4.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@fleetbase/ember-accounting 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/fleetbase__ember-accounting 是否存在。

@fleetbase/ember-accounting 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >= 18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@fleetbase/ember-accounting 可以商用吗?

@fleetbase/ember-accounting 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fleetbase/ember-accounting 的下载量有多少?

根据 npm 官方下载统计,@fleetbase/ember-accounting 在 2026/10/15 – 2026/11/13 这 30 天内被下载 4,111 次,日均约 137 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fleetbase/ember-accounting 还在维护吗?

最新版本 0.0.1 发布于 2023/12/20(2 年前);至今共发布 1 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/12/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。