{"id":13806096,"url":"https://github.com/cibernox/ember-cpm","last_synced_at":"2025-04-05T20:07:47.477Z","repository":{"id":9046271,"uuid":"10810592","full_name":"cibernox/ember-cpm","owner":"cibernox","description":"ComputedProperty Macros for Ember","archived":false,"fork":false,"pushed_at":"2018-10-28T23:27:54.000Z","size":769,"stargazers_count":275,"open_issues_count":10,"forks_count":31,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-10-18T07:58:23.808Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cibernox.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APLv2","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-06-20T02:25:03.000Z","updated_at":"2024-09-02T16:19:29.000Z","dependencies_parsed_at":"2022-07-09T22:30:31.006Z","dependency_job_id":null,"html_url":"https://github.com/cibernox/ember-cpm","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cibernox%2Fember-cpm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cibernox%2Fember-cpm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cibernox%2Fember-cpm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cibernox%2Fember-cpm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cibernox","download_url":"https://codeload.github.com/cibernox/ember-cpm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247393570,"owners_count":20931812,"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-08-04T01:01:07.835Z","updated_at":"2025-04-05T20:07:47.460Z","avatar_url":"https://github.com/cibernox.png","language":"JavaScript","funding_links":[],"categories":["Packages"],"sub_categories":["Data manipulation \u0026 Computed"],"readme":"## Ember-CPM\n\n[![Build Status](https://travis-ci.org/cibernox/ember-cpm.svg?branch=master)](https://travis-ci.org/cibernox/ember-cpm)\n[![Ember Observer Score](http://emberobserver.com/badges/ember-cpm.svg)](http://emberobserver.com/addons/ember-cpm)\n[![Code Climate](https://codeclimate.com/github/cibernox/ember-cpm/badges/gpa.svg)](https://codeclimate.com/github/cibernox/ember-cpm)\n[![Dependency Status](https://david-dm.org/cibernox/ember-cpm.svg)](https://david-dm.org/cibernox/ember-cpm)\n[![devDependency Status](https://david-dm.org/cibernox/ember-cpm/dev-status.svg)](https://david-dm.org/cibernox/ember-cpm#info=devDependencies)\n![Ember Version](https://embadge.io/v1/badge.svg?start=2.0.0)\n\nComputed Property Macros for Ember\n\n### Requirements\n\nVersion 2.0+ will only work with Ember 2.0+\nVersion 3.0+ is only tested in the last 2 LTS.\n\n### Installation\n\nJust run `ember install ember-cpm`\n\n\n### Usage\n\nJust import individual macros from `ember-cpm/macros/*` or all macros from `ember-cpm`.\n\n```js\n// Import only one macros\nimport ifNull from \"ember-cpm/macros/if-null\";\n// or alternatively import all the namespace\nimport EmberCPM from \"ember-cpm\";\n```\n\n\n### Contributing\n\nTo generate a new computed property macros with ember-cli\n\n* Run `ember g macro \u003cdasherized-macro-name\u003e`. This will generate a few files\n  * `./addon/macros/dasherized-macro-name.js` (the macro)\n  * `./addon/tests/dummy/unit/macro/dasherized-macro-name-test.js` (a test)*\n  * and modify `./addon/ember-cpm.js`\n\n```javascript\n// import the macro\nimport camelizedMacroName from './macros/dasherized-macro-name.js'\n...\n\nvar Macros = {\n  ...\n  // allows use via EmberCPM.Macros.camelizedMacroName\n  camelizedMacroName: camelizedMacroName,\n  ...\n};\n\n```\n`ember d macro \u003cdasherized-macro-name\u003e` will do the reverse of these changes\n\n### Provided Macros\n\n * `among` -- returns `true` if the original value is among the given literals\n   (testing using `===`)\n * `encodeURIComponent` -- calls `encodeURIComponent` on the original value\n * `encodeURI` -- calls `encodeURI` on the original value\n * `firstPresent` -- returns the first property with a value, as determined by `Ember.isPresent`\n * `fmt` -- pass the original values into a format-string\n * `htmlEscape` -- escapes the original value with\n   `Handlebars.Utils.escapeExpression` *and* wraps the result in a\n   `Handlebars.SafeString` (since it's now safe)\n * `ifNull` -- fall back on a default value\n * `promise` -- wraps the original value in an already-resolved promise\n * `safeString` -- wraps the original value in a `Handlebars.SafeString`\n * `join` -- joins the supplied values together with a provided sepatator\n * `quotient` -- divides one numeric property or literal by another\n * `difference` -- subtracts one numeric property or literal from another\n * `product` -- multiplies numeric properties and literals together\n * `sum` -- sums numeric properties and literals together\n * `conditional` -- returns values based on a boolean property (good replacement for ternary operator)\n * `computedPromise` -- Updates computed property when supplied callback (which must return a promise) is resolved\n\n### Composable Computed Property Macros\n\nUnlike Ember's computed property macros, the macros in this addon are *composable*. That means\nyou define macros inside other macros without defining them in a separate key.\n\n```javascript\nimport Ember from 'ember';\nimport EmberCPM from 'ember-cpm';\n\nconst { Macros: { sum, difference, product } } = EmberCPM;\n\nexport default Ember.Component.extend({\n  num1: 45,\n  num2: 3.5,\n  num3: 13.4,\n  num4: -2,\n\n  total: sum(\n    sum('num1', 'num2', 'num3'),\n    difference('num3', 'num2'),\n    product(difference('num2', 'num1'), 'num4')\n  )\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcibernox%2Fember-cpm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcibernox%2Fember-cpm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcibernox%2Fember-cpm/lists"}