{"id":17766618,"url":"https://github.com/floatdrop/bh-property-helpers","last_synced_at":"2025-08-04T14:42:18.311Z","repository":{"id":19023935,"uuid":"22247445","full_name":"floatdrop/bh-property-helpers","owner":"floatdrop","description":"Helpers for BH methods generation","archived":false,"fork":false,"pushed_at":"2014-07-26T16:15:59.000Z","size":192,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-09T16:17:05.645Z","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/floatdrop.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}},"created_at":"2014-07-25T06:33:38.000Z","updated_at":"2014-07-25T06:38:08.000Z","dependencies_parsed_at":"2022-08-20T20:20:23.331Z","dependency_job_id":null,"html_url":"https://github.com/floatdrop/bh-property-helpers","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fbh-property-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fbh-property-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fbh-property-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fbh-property-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/floatdrop","download_url":"https://codeload.github.com/floatdrop/bh-property-helpers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246651508,"owners_count":20811991,"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-26T20:33:26.083Z","updated_at":"2025-04-01T13:45:15.042Z","avatar_url":"https://github.com/floatdrop.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bh-property-helpers [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url]\n\nThis is helper for fast and nice property setter/getter creation in context object.\n\n__Important:__ It is slow.\n\n## Usage\n\n```js\nvar Method = require('bh-property-helpers');\n\nmethod = new Method({ protected: false });\n\nfunciton Context() {\n    function pickModsProperty() {\n        return '_object.' + (this._context.get('object').elem ? 'elemMods' : 'mods');\n    }\n\n    method(this)\n        .before(function () {\n            this._object = this._context.get('object');\n        })\n        .named('attr').changes('_object.attrs').property()\n        .named('attrs').changes('_object.attrs').property()\n        .named('bem').changes('_object.bem').value()\n        .named('cls').changes('_object.cls').value()\n        .named('content').changes('_object.content').value()\n        .named('js').changes('_object.js').value()\n        .named('param').changes('_object').property()\n        .named('tag').changes('_object.tag').value()\n        .named('mix').changes('_object.mix').array()\n        .named('mod').changes(pickModsProperty).property()\n        .named('mods').changes(pickModsProperty).object();\n}\n```\n\n## API\n\n### Method([options])\n\nConstructor of method builder. \nReturns `Builder`.\n\n### Builder(context)\n\nReturns builder for context object. All methods will be defined on this object.\nReturns `Builder`.\n\n#### .named(name)\n\nDefines name for the method.\nReturns `Builder`.\n\n#### .changes(propertyPath)\n\nPoints created method to propertyPath, which can be `String` or `Function`. In case of `Function` property path will be resolved each time method is called. \nReturns `Builder`.\n\n#### .value() / .property() / .array() / .object()\n\nThis methods tells builder about value type, with which created method will be working.\n\n| Type          | What it does                           | Setter/getter signature         |\n| ------------- | -------------------------------------- | ------------------------------- |\n| value()       | Just sets passed value to property     | `function (value, force)`       |\n| property()    | Sets key-value in property object      | `function (key, value, force)`  |\n| array()       | Appends passed value to Array property | `function (array, force)`       |\n| object()      | Extends property with passed object    | `function (object, force)`      |\n\nBy default this setters will not override previous property value (unless `force` is true). \n\nReturns `Builder`.\n\n\n[npm-url]: https://npmjs.org/package/bh-property-helpers\n[npm-image]: http://img.shields.io/npm/v/bh-property-helpers.svg\n\n[travis-url]: https://travis-ci.org/floatdrop/bh-property-helpers\n[travis-image]: http://img.shields.io/travis/floatdrop/bh-property-helpers.svg\n\n[coveralls-url]: https://coveralls.io/r/floatdrop/bh-property-helpers\n[coveralls-image]: http://img.shields.io/coveralls/floatdrop/bh-property-helpers/master.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloatdrop%2Fbh-property-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffloatdrop%2Fbh-property-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloatdrop%2Fbh-property-helpers/lists"}