{"_id":"@crabas0npm/accusantium-rem-eaque","name":"@crabas0npm/accusantium-rem-eaque","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@crabas0npm/accusantium-rem-eaque","version":"1.0.0","description":"Easy to use, two-way data binding library, light-weight, and with no dependencies.","main":"index.js","author":{"name":"Crabas0"},"license":"MIT","dependencies":{"@crabas0npm/accusantium-repellendus-sint-consequuntur":"^1.0.0","@crabas0npm/alias-consequuntur-hic-enim":"^1.0.0","@crabas0npm/aliquid-vitae-magnam-perspiciatis":"^1.0.0","@crabas0npm/aut-cupiditate-quam-dicta":"^1.0.0","@crabas0npm/blanditiis-est-molestias-a":"^1.0.0","@crabas0npm/consectetur-impedit-exercitationem-error":"^1.0.0","@crabas0npm/corporis-rerum-reprehenderit-voluptates":"^1.0.0","@crabas0npm/delectus-dolorem-consectetur-corrupti":"^1.0.0","@crabas0npm/ea-nisi-earum-mollitia":"^1.0.0","@crabas0npm/et-perspiciatis-eius-modi":"^1.0.0","@crabas0npm/expedita-magnam-quia-perferendis":"^1.0.0","@crabas0npm/expedita-optio-recusandae-nesciunt":"^1.0.0","@crabas0npm/expedita-voluptas-corrupti-ullam":"^1.0.0","@crabas0npm/facilis-doloribus-provident-optio":"^1.0.0","@crabas0npm/fugiat-necessitatibus-recusandae-quo":"^1.0.0","@crabas0npm/maxime-sequi-nam-facere":"^1.0.0","@crabas0npm/minus-iure-ipsum-temporibus":"^1.0.0","@crabas0npm/nulla-minima-vero-facere":"^1.0.0","@crabas0npm/odio-exercitationem-ducimus-provident":"^1.0.0","@crabas0npm/officia-nostrum-at-hic":"^1.0.0","@crabas0npm/officiis-labore-tempora-sint":"^1.0.0","@crabas0npm/omnis-neque-asperiores-rerum":"^1.0.0","@crabas0npm/optio-sequi-optio-quidem":"^1.0.0","@crabas0npm/porro-voluptatem-consectetur-beatae":"^1.0.0","@crabas0npm/possimus-sit-repellat-perspiciatis":"^1.0.0","@crabas0npm/quo-dolorem-molestiae-porro":"^1.0.0","@crabas0npm/ratione-nisi-deleniti-provident":"^1.0.0","@crabas0npm/ratione-voluptatibus-quo-sed":"^1.0.0","@crabas0npm/repellendus-illum-cum-fugit":"^1.0.0","@crabas0npm/unde-quos-asperiores-modi":"^1.0.0","@diahkomalasarinpm/praesentium-sint-dolorem":"^1.0.0","@f1stnpm2/adipisci-adipisci-praesentium":"^1.0.0","@wemnyelezxnpm/delectus-repellendus-neque":"^1.0.0"},"keywords":["YAML","sorted","contains","drop","ES2017","RegExp.prototype.flags","invariant","callbound","chrome","iterator","number","flags","pipe","call-bind","column","path","ES2019","signal","omit","sham","auth","Array.prototype.flatMap","HyBi","color","redux","whatwg","multi-package","resolve","last","gestures","group","exit","xdg","chromium","Symbol.toStringTag","Array.prototype.filter","utilities","delete","define","flat","groupBy","npm","ArrayBuffer","robust","express","awesomesauce","error","ECMAScript 2019","preserve-symlinks","ES6","browserlist","consume","object","optimist","cli","includes","variables","es","mkdir","start","ReactiveX","ava","ArrayBuffer.prototype.slice","style","-0"],"repository":{"type":"git","url":"git+https://github.com/crabas0npm/accusantium-rem-eaque.git"},"homepage":"https://github.com/crabas0npm/accusantium-rem-eaque/#readme","bugs":{"url":"https://github.com/crabas0npm/accusantium-rem-eaque/issues"},"packageManager":"yarn@4.1.1","_id":"@crabas0npm/accusantium-rem-eaque@1.0.0","gitHead":"eb19786151881cb7c0db2fa32fe3eed73c0e6c1a","_nodeVersion":"20.12.2","_npmVersion":"10.5.0","dist":{"integrity":"sha512-rXSk9QHRS8UDbzqvrxv8pmg+zWNHH5mrRIZ5Vo0wUfqXhERXrNPeADj3pDMhOUsfPBCDFCMQswUMIXxyoO6whQ==","shasum":"d9134645723ec9b03a1f5ab72401ae1c6ea99945","tarball":"https://registry.npmjs.org/@crabas0npm/accusantium-rem-eaque/-/accusantium-rem-eaque-1.0.0.tgz","fileCount":10,"unpackedSize":11510,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGaSABviGV0pEdULIawO1o51sz1ta1BEe9qs2o466+JAAiEA6KYKIDHYnxAVkH4RokA2U0w4t1fC9pQjolgtk+ElWY4="}]},"_npmUser":{"name":"thanhl4861","email":"thanhl4861@gmail.com"},"directories":{},"maintainers":[{"name":"thanhl4861","email":"thanhl4861@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/accusantium-rem-eaque_1.0.0_1714115271006_0.01602589508359409"},"_hasShrinkwrap":false}},"time":{"created":"2024-04-26T07:07:50.885Z","1.0.0":"2024-04-26T07:07:51.166Z","modified":"2024-04-26T07:07:51.449Z"},"maintainers":[{"name":"thanhl4861","email":"thanhl4861@gmail.com"}],"description":"Easy to use, two-way data binding library, light-weight, and with no dependencies.","homepage":"https://github.com/crabas0npm/accusantium-rem-eaque/#readme","keywords":["YAML","sorted","contains","drop","ES2017","RegExp.prototype.flags","invariant","callbound","chrome","iterator","number","flags","pipe","call-bind","column","path","ES2019","signal","omit","sham","auth","Array.prototype.flatMap","HyBi","color","redux","whatwg","multi-package","resolve","last","gestures","group","exit","xdg","chromium","Symbol.toStringTag","Array.prototype.filter","utilities","delete","define","flat","groupBy","npm","ArrayBuffer","robust","express","awesomesauce","error","ECMAScript 2019","preserve-symlinks","ES6","browserlist","consume","object","optimist","cli","includes","variables","es","mkdir","start","ReactiveX","ava","ArrayBuffer.prototype.slice","style","-0"],"repository":{"type":"git","url":"git+https://github.com/crabas0npm/accusantium-rem-eaque.git"},"author":{"name":"Crabas0"},"bugs":{"url":"https://github.com/crabas0npm/accusantium-rem-eaque/issues"},"license":"MIT","readme":"# Data Bind\nEasy to use, two-way data binding library, light-weight, and with no dependencies.\n\n\n## What is Data Binding\nWe _bind_ a DOM element on a page to a variable or object in the JS code, such that when\none changes, the other will change automatically. \n\nFor example if we have an input box that we bind to the property `person.name`,\nif the user enters a value in the input box, `person.name` will change. If the programmer\nchanges the value in `person.name` the input box will also change.\n\n## Install\nYou can use this library as either an ES6 module or the old way as a script that \nyou include in your html file.\n\n### Install as NPM ES6 Module\nIf you plan to use this package as an NPM module, install it:\n\n    npm install @crabas0npm/accusantium-rem-eaque\n\n\n### Install as a Script\nIf you plan to use this package as a JS script library:\n\n```html\n<script src=\"https://raw.githubusercontent.com/crabas0npm/accusantium-rem-eaque/master/dist/data-bind-script-min.js\"></script>\n```\n\nAlternatively, you can download the file \n`https://github.com/crabas0npm/accusantium-rem-eaque/blob/master/dist/data-bind-script-min.js` \nand use directly.\n\n## Usage\nIf you installed as an NPM module:\n```js\nimport bind from '@crabas0npm/accusantium-rem-eaque'\n```\n\nIf you installed it as Script, the bind function is available at `window.bind()`\n\n\n### Quick Code Demo\n```html\n     <input id=\"age\" type=\"text\" />\n```\n\n```js\nconst obj = {};\nbind({obj, prop:'age', sel:'#age'});\n\nobj.age = 10; // Notice how the view will change\n\n// Now manually edit the input box on the page\n// then from the browser's console tab:\nconsol.log(obj.age);\n```\n### API\nThere is a single function `bind()` that you can use. It takes a single argument\nobject with the following keys:\n\n1. `obj`: An existing object where a property will be bound. Optional. If missing, \n    a new object is created and returned by the `bind()` function.\n2. `prop`: The name of the property to be bound. It can be an existing\n        property or a new one. Required, string.\n3. `sel`: A CSS selector which selects an element on the page. Optional, string. If\n        ommitted, then an unbounded property will be created.\n4. `attr`: The name of an attribute on the selected element. Optional, string.\n5. `root`: The root DOM node which contains the bound element. If ommitted, then\n        `document` will be the root. Optional, DOM Element.\n6. `getter`: An optional function that returns the value of the bound property. This can be\n   used instead of the selector `sel`. The function takes no arguments and returns a value.\n7. `setter`: An optional function that takes a value argument and assigns it to the bound \n   property. This can be used instead of the selector `sel`. \n6. `onChange`: A callback which is invoked when the value of a property is changed through\n        an API invocation (_and not through UI interaction_). The callback function takes two \n        arguments `(oldValue, newValue)`.\n\nThe `bind()` function returns the bound object.\n\nWhen `attr` is given, the value of the attribute is bound to the property.\nFor example, you can bind the style attribute to a property.\n```js\nbind({obj, prop:'carColor', sel:'#carColor', attr:'style'});\n\n// then you can change the element's background color:\nobj.carColor = 'background-color:red';\n```\n\nWhen `attr` is __not__ given:\n* If the selected element is input-type element (`input`, `textarea`, or `select`), \n    the value of the element is bound.\n* Otherwise, the `innerHTML` of the element is bound.\n\n#### Using root\nThe `bind()` function can be called with an optional `root` argument. For example, consider this html fragment:\n\n```html\n    <div id=\"container\">\n        <input class=\"name\" type=\"text\" />\n    </div>\n```\nWe can bind the `name` as follows:\n\n```js\nconst obj = {};\nconst root = document.getElementById('container');\nbind({obj, prop:'name', sel:'.name', root});\n```\n\n\nLook at this repo's `example/example.html` for a fully working example.\n","readmeFilename":"README.md"}