{"name":"svelte-extras","version":"2.0.1","description":"Extra methods for Svelte components","main":"dist/svelte-extras.cjs.js","module":"dist/svelte-extras.es.js","scripts":{"build":"rollup -c","lint":"eslint src","prepublish":"npm run lint && npm test","test":"mocha","pretest":"npm run build"},"files":["dist"],"repository":{"type":"git","url":"git+https://github.com/sveltejs/svelte-extras.git"},"keywords":["svelte"],"author":{"name":"Rich Harris"},"license":"MIT","bugs":{"url":"https://github.com/sveltejs/svelte-extras/issues"},"homepage":"https://github.com/sveltejs/svelte-extras#readme","devDependencies":{"@types/node":"^9.6.5","console-group":"^0.3.3","eslint":"^4.2.0","eslint-plugin-import":"^2.7.0","jsdom":"^11.8.0","mocha":"^5.1.1","rollup":"^0.58.1","rollup-plugin-buble":"^0.19.2","rollup-plugin-typescript":"^0.8.1","rollup-plugin-virtual":"^1.0.1","svelte":"^2.0.0","typescript":"^2.4.2"},"peerDependencies":{"svelte":"^2"},"gitHead":"ab81e7de6379e8cc7fc3afa3fea1469cd381a4b8","_id":"svelte-extras@2.0.1","_npmVersion":"5.6.0","_nodeVersion":"9.11.1","_npmUser":{"name":"rich_harris","email":"richard.a.harris@gmail.com"},"dist":{"integrity":"sha512-bfUNvnmUaz5QAF/LQWER+xPPwMHfW/lqRumR7trIi3wpTZhrguF+KX6Z4d0uZ3l3X3PjXcV22/4FQT1hdqyT+A==","shasum":"840527a03e900d0881ef91c0f936a8569e4089a8","tarball":"http://registry-npm.ywwl.com/svelte-extras/download/svelte-extras-2.0.1.tgz","fileCount":7,"unpackedSize":60219,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa2LXKCRA9TVsSAnZWagAAJhsP/A1UbHUW6Oz3rLLWrbDy\nlEO6ZYQDew58mGkqKZnn+p3xgax0Y5DB7iSBM03WQMpntt//HB/z55flh6eT\n7p8sD9uC3zZiLO9oLokZwybspz+om9gAQ+Xkhmm5AlJLRU4oHDtk4E00+Zmt\nEkmhESKbN5KuLnUnXhhNPGTQOlpGuQMm6CuJCvmoGbElxkvMBOKfg2dbwadE\nGp2KCXSlHcrvbzOKmNmU6UBc8FPgwn7xnGoisAJ73bz22rj5zZI71tCr8pr/\nalG5cUwQxvGmk3QrGyARLpz/k8X0dRejX3rId4/jK8dkbk/NaPP/vM9An05M\ny5UVzwLquc8Bur56KGjCmU0mCZdOmg91HEx0Mv63pWkNgEAweswR9H63iLbT\np3HJVgeUZjKfXM8Y4KY9AMi4qUc7wht64BkKjtfca0/wueWUt/FRn1Jtn1UV\nRF8k/wEimq8nAGigvRgV72t5ff4/eJov+4wBV1YuHoQxoOaLydsHryDLdTGo\np9CKpWWs265OtU5T0pH1Etge6DfTK8ZQ/+cIr7zxBILsPY6Y/zMxLU+1PQ9D\nNVxlIRzptuX3jlM4sYSpsiYrlVYC+zOrxCaIVoAxs5WZ8fv/pPpOXOV2WASC\n11UMUcLcTPYsKOVpJqeVty9StHF5JFP3svCAjo55LSs8OOP6XXVQuDCyZoIK\nYVtS\r\n=mMu0\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCrCo3U6ThfGw+YUj2RFP7rWyng4AsUpL5rNEp1DJSXWwIgWDVKt3Hf1H2if1kkmSmnDZMyD7YB+P7vryQuhiMEdAA="}],"size":9634,"noattachment":false,"key":"/svelte-extras/-/svelte-extras-2.0.1.tgz"},"maintainers":[{"name":"rich_harris","email":"richard.a.harris@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svelte-extras_2.0.1_1524151753443_0.8888502539062966"},"_hasShrinkwrap":false,"readme":"# svelte-extras\n\nExtra methods for [Svelte](https://svelte.technology) components.\n\n## Usage\n\nInstall with npm or yarn...\n\n```bash\nnpm install --save svelte-extras\n```\n\n...then add to your component methods:\n\n```html\n<input bind:value='newTodo'>\n<button on:click='push(\"todos\", newTodo)'>add todo</button>\n\n<ul>\n  {{#each todos as todo, i}}\n    <li>\n      <button on:click='splice(\"todos\", i, 1)'>x</button>\n      {{todo}}\n    </li>\n  {{/each}}\n</ul>\n\n<script>\n  import { push, splice } from 'svelte-extras';\n\n  export default {\n    data: function () {\n      return {\n        newTodo: '',\n        todos: ['add some more todos']\n      };\n    },\n\n    methods: {\n      push,\n      splice\n    }\n  };\n</script>\n```\n\n## Available methods\n\n### Array methods ([live demo](https://svelte.technology/repl?gist=30b8d79ac7a7ce11076df68366cc0134))\n\n* push\n* pop\n* shift\n* unshift\n* splice\n* sort\n* reverse\n\nThese all work exactly as their `Array.prototype` counterparts, except that the first argument must be the *keypath* that points to the array. The following are all examples of keypaths:\n\n```js\ncomponent.push('todos', 'finish writing this documentation');\ncomponent.push('foo.bar.baz', 42);\ncomponent.push('rows[4]', cell);\n```\n\n### tween(key, end, options?) ([live demo](https://svelte.technology/repl?gist=f3d3c58264886987afcf09a0c8e07776))\n\nSmoothly tweens `key` from its current value to the `end` value. Numerical values (and non-cyclical objects and arrays, as long as their leaf properties are numerical) are automatically interpolated, or you can supply a custom function.\n\nThe available options (and default values) are:\n\n* **delay** (0) — the delay in milliseconds before the tween starts\n* **duration** (400) — the duration of the tween\n* **easing** (x => x) — which easing function to use (see e.g. [eases-jsnext](https://github.com/rollup/eases-jsnext)))\n* **interpolate** (see above) — a function that generators a custom interpolator, for e.g. transitioning strings representing colors. Must take arguments `a` and `b` and return a function that takes a value `t` between 0 and 1\n\nThis method returns a promise with an additional `abort` method. The tween will be aborted automatically if `key` is updated separately, either by a second tween or via `component.set(...)`. The promise will not resolve if the tween is aborted.\n\n### spring(key, end, options) ([live demo](https://svelte.technology/repl?version=1.38.0&gist=8def8776479d3d74b3b2829af3b01074))\n\nSimilar to `tween`, except it uses a spring physics simulation rather than a pre-defined easing curve, which gives more natural results in some situations. The `end` value can be anything you could pass to `tween`.\n\nThe following options must be provided:\n\n* **stiffness** — the *spring constant*, a value between 0 and 1\n* **damping** — the *damping coefficient*, again between 0 and 1\n\nFiguring out the optimal combination of stiffness and damping typically takes a bit of trial and error. The higher the stiffness, the quicker the motion will be; the lower the damping, the 'springier' it will be.\n\nThis method returns a promise that resolves when the simulation is complete — or not at all, if the simulation is aborted by another call to `spring(...)` or a call to `set(...)`.\n\n\n### observe(key, callback, options?)\n\nRuns the `callback` function with two arguments, `newValue` and `oldValue`, every time the value of `key` changes. `options` can contain two booleans — `init`, which determines whether to fire the callback immediately (the default) instead of waiting for a change, and `defer`, which determines whether the callback fires before or after the DOM has updated.\n\nThis method used to be built in to Svelte; it's now recommended that you use the `onstate` and `onupdated` lifecycle hooks instead.\n\n\n### observeDeep(keypath, callback, options?) ([live demo](https://svelte.technology/repl?gist=589949dc19c7dea17deb6c06243ba66d))\n\nExactly the same as `observe` method, except that it observes nested properties of objects and arrays, rather than the objects themselves. The `keypath` option is a string like `foo.bar` (observe the `bar` property of the `foo` object) or `baz[0]` (observe the first member of the `baz` array).\n\n\n### observeMany(keys, callback, options?) ([live demo](https://svelte.technology/repl?gist=bdb1eb4553e87e191884d32c84355852))\n\nObserves multiple keys, without firing multiple times when they change simultaneously. `keys` is an array of keys, while the callback receives two arguments — an array of the new values corresponding to those keys, and an array of the old values. `options` can include `init` and `defer`, like the built-in `observe` method.\n\n\n### getDeep(keypath) ([live demo](https://svelte.technology/repl?gist=3b32e284732a6297fc49a213930a3cf0))\n\nSimilar to the built-in `get` method, except that it gets nested properties of objects and arrays, rather than the objects themselves. The `keypath` option is a string like `foo.bar` (get the `bar` property of the `foo` object) or `baz[0]` (get the first member of the `baz` array).\n\n\n### setDeep(keypath, value) ([live demo](https://svelte.technology/repl?gist=6dc00bf661849b14ac79439d91becd6d))\n\nSimilar to the built-in `set` method, except that it sets nested properties of objects and arrays, rather than the objects themselves. The `keypath` option is a string like `foo.bar` (set the `bar` property of the `foo` object) or `baz[0]` (set the first member of the `baz` array).\n\n\n## Tree-shaking\n\nIf you're using a module bundler that supports tree-shaking, such as [Rollup](https://rollupjs.org), only the methods your components use will be included in your app.\n\n\n## Universal module definition\n\nIf you *really* need it, a UMD build is available at [svelte-extras/dist/svelte-extras.umd.js](https://unpkg.com/svelte-extras/dist/svelte-extras.umd.js), and will register itself as `svelte.extras`. We recommend using a module bundler instead, however.\n\n\n## License\n\n[MIT](LICENSE)\n","publish_time":1524151753511,"_cnpm_publish_time":1524151753511,"dist-tags":{"latest":"2.0.2"}}