{"name":"@arrows/dispatch","version":"0.2.0","main":"lib/index.js","license":"ISC","scripts":{"build":"tsc","test":"jest","coverage":"jest --coverage && codecov -F dispatch","prepublish":"yarn build"},"devDependencies":{"@types/jest":"^24.0.18","codecov":"^3.6.0","jest":"^24.9.0","ts-jest":"^24.1.0","typescript":"^3.6.3"},"description":"![CircleCI](https://img.shields.io/circleci/build/github/caderek/arrows) ![David (path)](https://img.shields.io/david/caderek/arrows?path=packages%2Fdispatch)","_id":"@arrows/dispatch@0.2.0","_nodeVersion":"10.16.0","_npmVersion":"6.10.1","dist":{"integrity":"sha512-H04kkRQaOISotPouWieeETvX7jn3DWpd+49uypl6xVkYQ9WLJHjktcG5XkNDRhS5px8zCviDfcrbJZo30JMe7w==","shasum":"52b909b112e855ffabe355b2bd9268c96bb98cf8","tarball":"http://registry-npm.ywwl.com/@arrows/dispatch/download/@arrows/dispatch-0.2.0.tgz","fileCount":23,"unpackedSize":10194,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdhY6jCRA9TVsSAnZWagAAbS0P/038lbjEpwG830+ze/dC\nEEvYm54PQl2mhxaNLS+i9xXJdp4uySK6+1HcfSONyipSER8pDrW7NrXqr7mN\no+lJ2Ybtrv9KfJs5Grp5sVNivM3y+YwqsLiv9y2PiXs5Xt30XC7xqCrnqKtB\nVcp4bJxjhGVlrDYPT3dQtpI5XJQJg01M2ZGzzBse6EH+09Kab7mQ+glr+86W\nSIQR7xb0R1R31ZW3aqPHP5Lw0QSg4vFKFAtobfTCCZQ3KMsjIOaVRrtYI401\nWNkCZGMW9j9b5jXG8Sh2/Wr/6ZYBLY0jn4UZOQFtvdXk12fE+2teLuVi4djs\njQnrHx1BXqb9U7GCMo2iTMf20d4+ov66KLOSVA5lVcEec/LjQyzeP7sND3b6\n+XxLEN0oDp5IYbT/dlcXuT3fa+oFZlXRN1K0XXZDFQNON0y652ZHmJeu7iyV\nGH9aGnlxxGMx6TyIEEp/DO2r0LoLXmN05s7HuYVzNK2EEPvI+sEfUw1eond8\nPpmgru2zJwJeYiugGFlJ/ZWxk95QVIRVyoGFOnB+PtTd1jVwg9IFec/lOgqD\njmw9372PGmcG89PVlCTYJZixspj0MDstRuZW0WV117R3S9gwgilTO0DhkRFh\nksOAHmxOihQg2PXqb+xbYSmAAYConVJlLgTkAmhYYS1uYnm9sGmW3wftY3ri\nyCux\r\n=oG1k\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCAJxhI79hwhfwd6oMUxIXSj245ZpnfobCPxMZYDF/ZCwIhAOu9GsFTSqazyNNQo709fTS1tuXsP2soSVzZMA5TVt9/"}],"size":3208,"noattachment":false,"key":"/@arrows/dispatch/-/@arrows/dispatch-0.2.0.tgz"},"maintainers":[{"name":"caderek","email":"maciej.caderek@gmail.com"}],"_npmUser":{"name":"caderek","email":"maciej.caderek@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dispatch_0.2.0_1569033891427_0.3302445071224731"},"_hasShrinkwrap":false,"readme":"![arrows - dispatch](https://raw.githubusercontent.com/caderek/arrows/master/assets/arrows-dispatch.svg?sanitize=true)\n\n# @arrows/dispatch\n\n![npm (scoped)](https://img.shields.io/npm/v/@arrows/dispatch)\n![CircleCI](https://img.shields.io/circleci/build/github/caderek/arrows)\n![David (path)](https://img.shields.io/david/caderek/arrows?path=packages%2Fdispatch)\n![Codecov](https://img.shields.io/codecov/c/github/caderek/arrows?token=c6adb715d638431786fefe69ca08ab00)\n![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/@arrows/dispatch)\n![GitHub](https://img.shields.io/github/license/caderek/arrows)\n\n## Table of contents\n\n1. [Introduction](#introduction)\n2. [Installation](#installation)\n3. [API reference](#api-reference)\n   - [getType](#getType)\n   - [identity](#identity)\n   - [is](#is)\n   - [isIn](#isIn)\n   - [types](#types)\n4. [License](#license)\n\n## Introduction\n\nThe library contains a collection of dispatch functions.\nAll functions with the arity (number of arguments) greater than one are automatically curried, so a partial application is possible.\n\nThe library has **built-in type definitions**, which provide an excellent IDE support.\n\n## Installation\n\nVia NPM:\n\n```sh\nnpm i @arrows/dispatch\n```\n\nVia Yarn:\n\n```sh\nyarn add @arrows/dispatch\n```\n\nAll modules can be imported independently (to reduce bundle size), here are some import methods (you can use either CommonJS or ES modules):\n\n```js\nimport dispatch from '@arrows/dispatch'\n```\n\n```js\nimport { getType } from '@arrows/dispatch'\n```\n\n```js\nimport getType from '@arrows/dispatch/getType'\n```\n\n## API reference\n\n### getType\n\nRetrieves the type of a value (using the internal `[[Class]]` property).\nA more useful alternative for the `typeof` operator.\n\nIt does not return custom prototypes - if you need that, use the `is` function instead.\n\n_See: [types](#types) for the list of the most common values._\n\n_See: [MDN - Object.prototype.toString.call](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString#Using_toString_to_detect_object_class)_\n\n#### Parameters\n\n- `value` - Any value\n\n#### Returns\n\n- Returns an underlying class as a string.\n\n#### Interface\n\n```\n(value) => underlying_class_name\n```\n\n#### Example\n\n```javascript\ngetType(1) // -> \"Number\"\ngetType(/abc/) // -> \"RegExp\"\ngetType([1, 2, 3]) // -> \"Array\"\n```\n\n---\n\n### identity\n\nStandard identity function - useful as a default dispatch or a placeholder.\n\n#### Parameters\n\n- `value` - Any value\n\n#### Returns\n\n- Returns the argument as-is.\n\n#### Interface\n\n```\n(value) => value\n```\n\n#### Example\n\n```javascript\nidentity('foo') // -> \"foo\"\nidentity([1, 2, 3]) // -> [1, 2, 3]\n```\n\n---\n\n### is\n\nChecks if a value is an instance of a prototype/class.\n\n#### Parameters\n\n- `prototype` - A prototype/class with which you want to check the value.\n- `value` - Any value\n\n#### Returns\n\n- Returns `true` is a value is an instance of a prototype/class, `false` otherwise.\n\n#### Interface\n\n```\n(prototype, value) => boolean\n```\n\n#### Example\n\n```javascript\nclass Cat {}\nclass Dog {}\n\nconst cat = new Cat()\nconst dog = new Dog()\n\nis(Cat, cat) // -> true\nis(Dog, cat) // -> false\n\nis(Cat)(cat) // -> true\nis(Dog)(cat) // -> false\n```\n\n---\n\n### isIn\n\nChecks if a value is inside an array/set.\n\n#### Parameters\n\n- `list` - An array or a set of values\n- `value` - Any value\n\n#### Returns\n\n- Returns `true` is a value is inside an array/set, `false` otherwise.\n\n#### Interface\n\n```\n(array_or_set, value) => boolean\n```\n\n#### Examples\n\n```javascript\nconst names = ['Alice', 'Joe', 'John']\n\nisIn(names, 'Alice') // -> true\nisIn(names, 'Bob') // -> false\n\nisIn(names)('Alice') // -> true\nisIn(names)('Bob') // -> false\n```\n\n```javascript\nconst names = new Set(['Alice', 'Joe', 'John'])\n\nisIn(names, 'Alice') // -> true\nisIn(names, 'Bob') // -> false\n\nisIn(names)('Alice') // -> true\nisIn(names)('Bob') // -> false\n```\n\n---\n\n### types\n\nAn object that contains a list of the most common types to use with the [getType](#getType) function. You can use it instead of using raw strings (which is error-prone).\n\n#### Example\n\n```javascript\ngetType([1, 2, 3]) === types.Array // -> true\n\ngetType(() => null) === types.Function // -> true\n\ngetType(Promise.resolve()) === types.Promise // -> true\n\ngetType('1') === types.Number // -> false\n```\n\n## License\n\nProject is under open, non-restrictive [ISC license](LICENSE).\n","publish_time":1569033891538,"_cnpm_publish_time":1569033891538,"dist-tags":{"latest":"1.0.3"}}