{"id":20392378,"url":"https://github.com/wiseplat/meteor-package-tools","last_synced_at":"2026-05-09T08:04:23.624Z","repository":{"id":122792526,"uuid":"120946638","full_name":"WISEPLAT/meteor-package-tools","owner":"WISEPLAT","description":null,"archived":false,"fork":false,"pushed_at":"2018-02-09T19:29:04.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-10T13:33:37.352Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WISEPLAT.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-09T19:28:41.000Z","updated_at":"2018-02-09T19:29:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"e428bafd-e717-4fe8-9ac0-1beb801040d6","html_url":"https://github.com/WISEPLAT/meteor-package-tools","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/WISEPLAT/meteor-package-tools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WISEPLAT%2Fmeteor-package-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WISEPLAT%2Fmeteor-package-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WISEPLAT%2Fmeteor-package-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WISEPLAT%2Fmeteor-package-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WISEPLAT","download_url":"https://codeload.github.com/WISEPLAT/meteor-package-tools/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WISEPLAT%2Fmeteor-package-tools/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32811662,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"online","status_checked_at":"2026-05-09T02:00:06.633Z","response_time":123,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T03:43:34.345Z","updated_at":"2026-05-09T08:04:23.581Z","avatar_url":"https://github.com/WISEPLAT.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wiseplat tools\n\nA set of helper functions for wiseplat dapps.\n\nSee here for a [demo of the template helpers](http://localhost:4000/#tools).\n\n## Installation\n\nYou can either add it as a Meteor package using:\n\n    $ Meteor add wiseplat:tools\n\nor add link to the `wshtools.js` in your HTML.\n\n\n## Usage\n\nThis package provides formating and converting functionality.\n\nWhen using the `WshTools.ticker` it will call the [cryptocompare.com public API](https://min-api.cryptocompare.com/data/price?fsym=WSH\u0026tsyms=BTC,USD,EUR) every 30s to retrive price information for wise.\nWhen used as a Meteor package, the following units are possible for some methods:\n\n    - `btc`\n    - `usd`\n    - `eur`\n    - `cad`\n    - `gbp`\n    - `jpy`\n    - And all wise units ('wise', 'finney', 'wei', etc)\n\n**Note** As non-meteor package you can only use the wise units.\n\n***\n\n### WshTools.ticker\n\n    WshTools.ticker.start();\n    WshTools.ticker.findOne(unit)\n\n**Note** This is only available when used as a Meteor package.\n\nTo start polling for ticker prices run `WshTools.ticker.start()`\n\nIt gives you the latest price for wise based on the [kraken.com public API](https://api.kraken.com/0/public/Ticker?pair=XWSHZEUR,XXBTZUSD).\n`WshTools.ticker` is a reactive collection, so when used in a reactive function it will re-run this function when the price is updated.\n\nThe ticker will be updated every 30 seconds.\n\n**Methods**\n\nIts a normal Meteor collection\n\n- `start(options)` - starts the polling for the ticker, the options object can be an object with `{extraParams: 'mydata'}` to be added to the ticker polling call\n- `findOne(unit)` - returns an object with the price of the unit\n- `find().fetch()` - returns all available price ticker units\n\n**Returns**\n\n- `Object`\n```js\n{\n    _id: 'btc',\n    price: '0.02000'\n}\n```\n\n**Example**\n```js\nvar usd = WshTools.ticker.findOne('usd')\n\nif(usd)\n    console.log(usd.price) // \"2.0000\"\n```\n\n***\n\n### WshTools.setLocale\n\n    WshTools.setLocale(locale)\n\nSet the locale to display numbers differently in other countries.\nThis functions lets `WshTools.formatBalance()` and `WshTools.formatNumber()` reactivly re-run, to show the new format.\n\n**Parameters**\n\n- `locale` (`String`) - the locale to set\n\n**Returns**\n\n`String` - the set locale e.g. `en`\n\n**Example**\n\n```js\nWshTools.setLocale('de');\nWshTools.formatNumber(2000, '0,0.00');\n// 2 000,00\n```\n\n***\n\n### WshTools.setUnit\n\n    WshTools.setUnit(unit)\n\n**Note** This is only available when used as a Meteor package.\n\nReactivly sets a unit used as default unit, when no unit is passed to other WshTools methods.\nAnd also persists it in localstorage so its the same when you reload you app.\n\nDefault is unit `wise`.\n\n**Parameters**\n\n- `unit` (`String`) - the unit to set, see [Usage](#usage) for more\n\n**Returns**\n\n`Boolean` - TRUE if the unit is an allowed unit and could be set\n\n**Example**\n\n```js\nWshTools.setUnit('btc');\n\nTracker.autorun(function(){\n    var amount = WshTools.formatBalance('23000000000000000000', '0,0.0[00] unit');\n    // amount = \"0.287 btc\"\n});\n```\n\n***\n\n### WshTools.getUnit\n\n    WshTools.getUnit()\n\n**Note** This is only available when used as a Meteor package.\n\nReactivly gets the current set default unit, used byt other WshTools methods when no unit was passed.\nAnd also persists it in localstorage so its the same when you reload you app.\n\nDefault is unit `wise`.\n\n\n**Parameters**\n\nnone\n\n**Returns**\n\n`String` - the current default unit.\n\n**Example**\n\n```js\nWshTools.setUnit('btc');\n\nTracker.autorun(function(){\n    var unit = WshTools.getUnit();\n    // unit === 'btc'\n});\n\n```\n\n***\n\n### WshTools.formatNumber\n\n    WshTools.formatNumber(number, format)\n\nFormats any number using [numeral.js](http://numeraljs.com), e.g. `\"0,0.00[0000]\"`.\n\n**Parameters**\n\n- `number` (`String|Number`) - the number to format\n- `format` (`String`) - the format see [numeral.js](http://numeraljs.com) for examples, e.g. `\"0,0.00[0000]\"`\n\n**Returns**\n\n`String` - the formated number.\n\n**Example**\n\n```js\nvar finney = WshTools.formatNumber(2000, '0,0.00');\n// finney = '2,000.00'\n```\n***\n\n#### Format number template helper\n\n**Usage**\n\n```html\n{{dapp_formatNumber \"1000000133\" \"0,0.00[0000]\"}}\n```\n\n***\n\n### WshTools.formatBalance\n\n    WshTools.formatBalance(wei, format, unit)\n\nFormats a number of wei into any other wiseplat unit and other currencies (see [Usage](#usage)).\n\nDefault is unit `wise`.\n\nThe `format` property follows the [numeral.js](http://numeraljs.com) formatting, e.g. `\"0,0.00[0000]\"`.\nAdditionally you can add `\"unit\"` or `\"UNIT\"` (for uppercase) to display the unit after or before the number the number.\n\nAdditionally this function uses the reactive `WshTools.getUnit()` variable, when no `unit` was given.\nYou can then reactivly change the unit using `WshTools.setUnit('finney')`\n\n**Parameters**\n\n- `wei` (`String|Number`) - the amount of wei to convert and format\n- `format` (`String`) - the format see [numeral.js](http://numeraljs.com) for examples, e.g. `\"0,0.00[0000]\"`.\n- `unit` (`String`) - (optional) the unit to convert the given wei amount to, if not given it will use `WshTools.getUnit()`\n\n**Returns**\n\n`String` - the formated balance.\n\n**Example**\n\n```js\nvar amount = WshTools.formatBalance(112345676543212345, '0,0.0[00] unit', 'finney');\n// amount = \"112.346 finney\"\n```\n\n***\n\n#### Format balances template helper\n\n![format balances](https://raw.githubusercontent.com/wiseplat/meteor-package-elements/master/screenshots/formatBalance.png)\n\n**Usage**\n\n```html\n{{dapp_formatBalance \"1000000133\" \"0,0.00[0000]\" \"wise\"}}\n```\n\nIf you leave the last value it will use `WshTools.getUnit()`, as reactive localstorage variable.\n\n```html\n{{dapp_formatBalance \"1000000133\" \"0,0.00\"}}\n```\n\nUse then `WshTools.setUnit(finney')` to change the unit and displayed balances.\n\n***\n\n### WshTools.toWei\n\n    WshTools.toWei(number, unit)\n\nFormats an amount of any supported unit (see [Usage](#usage)) into wei.\n\nDefault is unit `wise`.\n\nAdditionally this function uses the reactive `WshTools.getUnit()` variable, when no `unit` was given.\nYou can then reactivly change the unit using `WshTools.setUnit('finney')`\n\n**Parameters**\n\n- `number` (`String|Number`) - the number of a unit, see [Usage](#usage) for more\n- `unit` (`String`) - the unit of the given number\n\n**Returns**\n\n`String` - the number in wei.\n\n**Example**\n\n```js\nvar wei = WshTools.toWei(23, 'btc');\n// wei = \"80000000000000000000\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiseplat%2Fmeteor-package-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwiseplat%2Fmeteor-package-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiseplat%2Fmeteor-package-tools/lists"}