{"id":15501974,"url":"https://github.com/luzlab/meteor-quantities","last_synced_at":"2025-04-05T06:23:01.916Z","repository":{"id":128979589,"uuid":"123084648","full_name":"luzlab/meteor-quantities","owner":"luzlab","description":null,"archived":false,"fork":false,"pushed_at":"2018-01-18T06:56:58.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-10T14:12:13.639Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":false,"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/luzlab.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-27T06:36:36.000Z","updated_at":"2018-02-27T06:36:37.000Z","dependencies_parsed_at":"2023-06-15T04:15:30.690Z","dependency_job_id":null,"html_url":"https://github.com/luzlab/meteor-quantities","commit_stats":{"total_commits":13,"total_committers":3,"mean_commits":4.333333333333333,"dds":"0.46153846153846156","last_synced_commit":"b95bbaa145d440c0a8bd943acdc219a83d1267be"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luzlab%2Fmeteor-quantities","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luzlab%2Fmeteor-quantities/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luzlab%2Fmeteor-quantities/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luzlab%2Fmeteor-quantities/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luzlab","download_url":"https://codeload.github.com/luzlab/meteor-quantities/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247296135,"owners_count":20915585,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-10-02T09:06:47.881Z","updated_at":"2025-04-05T06:23:01.893Z","avatar_url":"https://github.com/luzlab.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FATHOM:Quantities\n\nThis packages add support to Meteor for using numbers with phyiscal units. This package Meteor-izes the [js-quantities npm module](https://www.npmjs.com/package/js-quantities), adding the necessary methods to support serialization and deserialization by Meteor. This allows the use of quanties in publications, Meteor methods and arguments.\n\n# Example usage\n\n```\nimport Qty from 'meteor/fathom:quantities';\n\nif (Meteor.isServer) {\n    Meteor.methods({\n      'is_10cm': function is_10cm(qty) {\n            let ten_cm = Qty('10 cm');\n            let result = qty.eq(ten_cm);\n            return result;\n        }\n    );\n}\n\nlet qty2 = Qty('0.1 m');\nMeteor.call('is_10cm', qty2) // returns true\n\nlet weight = Qty('1.1 g');\nlet volume = Qty('1 cm^3');\nlet density = weight.div(volume);\n\nlet sample_volume = Qty('0.1 m^3');\nlet sample_weight = sample_volume.add(density); // returns QtyError 'Incompatible units'\nlet sample_weight = sample_volume.div(density); // Note - we should multiple, not divide, by density\nsample_weight.toString('kg'); // returns QtyError 'Incompatible units' since we dividied by density...\n\nlet sample_weight = sample_volume.mul(density); // Do the right operation with density\nsample_weight.toString('kg'); // returns '110 g' // Now these work as expected\nsample_weight.toString('lb'); // returns the '242.50848840336533 lb'\nsample_weight.toString('lb', 2); // returns the '242.51 lb'\nsample_weight.toString('m'); // returns QtyError 'Incompatible units'\n```\n\nThis package uses the npm module [`ejson-extras`](https://www.npmjs.com/package/ejson-extras) to registers a custom EJSON type for Qty objects. In addition, this package extends Qty.prototype to provide readable output when logging. Altogether, the Qty.prototype is extended with the following methods:\n\n* .typeName() - returns 'js-quantity'\n* .toJSONValue() - returns a JSON-ifyable string\n* .clone() - Returns a new Qty object equal to the argument.\n* .equals() - defers to Qty.eq() method if units are compatible; false otherwise\n* .inspect() - returns human-readable representation of the Qty (eg. \"12.1 m\") instead of dumping the internal JSON representation.\n\n# Changelog\n\n1.0.6 Updated ejson-extras module to fix Map stringify/parse bug\n\n1.0.5 Added missing test dependancies\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluzlab%2Fmeteor-quantities","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluzlab%2Fmeteor-quantities","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluzlab%2Fmeteor-quantities/lists"}