{"name":"svelte-extras","version":"1.0.0","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":"^7.0.18","eslint":"^3.19.0","eslint-plugin-import":"^2.2.0","jsdom":"^10.1.0","mocha":"^3.3.0","rollup":"^0.41.6","rollup-plugin-buble":"^0.15.0","rollup-plugin-typescript":"^0.8.1","svelte":"^1.20.2","typescript":"^2.3.2"},"gitHead":"525a0f8575784dc877d78c0993c9f27fb20fc26f","_id":"svelte-extras@1.0.0","_shasum":"d43c8087187ea17378960969937140363ce7bbaa","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.8.0","_npmUser":{"name":"rich_harris","email":"richard.a.harris@gmail.com"},"dist":{"shasum":"d43c8087187ea17378960969937140363ce7bbaa","tarball":"http://registry-npm.ywwl.com/svelte-extras/download/svelte-extras-1.0.0.tgz","integrity":"sha512-Fq3/AbiJ5I781PFGQlwGu/9OwxyydjdCyIp7b0ItDOFUOCVvS/pW/qIYXGm8xCN3BiJC0kRq40VcyJNnwrK5bQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDPi0Yl7SjsRqvt55iC0wADBgJyJBkiIcWNlSnGUo9trAIhAK/bCxaJItOEsgJpokw89TyCSFv2F+PeDTI5cflzoeRr"}],"size":2734,"noattachment":false,"key":"/svelte-extras/-/svelte-extras-1.0.0.tgz"},"maintainers":[{"name":"rich_harris","email":"richard.a.harris@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/svelte-extras-1.0.0.tgz_1494184217065_0.8994544029701501"},"directories":{},"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":1494184218992,"_cnpm_publish_time":1494184218992,"dist-tags":{"latest":"2.0.2"}}