{"_id":"to-key","_rev":"4-24ca64d74d97737400b840fa8193a1ac","name":"to-key","description":"Stringify any value to be used as the key of an object.","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"to-key","description":"Stringify any value to be used as the key of an object.","version":"1.0.0","homepage":"https://github.com/jonschlinkert/to-key","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git://github.com/jonschlinkert/to-key.git"},"bugs":{"url":"https://github.com/jonschlinkert/to-key/issues"},"license":{"type":"MIT","url":"https://github.com/jonschlinkert/to-key/blob/master/LICENSE"},"files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"arr-map":"^1.0.0","for-in":"^0.1.3","kind-of":"^1.1.0"},"devDependencies":{"benchmarked":"^0.1.3","chalk":"^0.5.1","glob":"^4.3.5","mocha":"^2.1.0","should":"*"},"keywords":["cache","key","object","property","string","stringify","to","to-string","tostring"],"_id":"to-key@1.0.0","_shasum":"2390fc76bb2aa3f56759985ca763bb4515789f2a","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"2390fc76bb2aa3f56759985ca763bb4515789f2a","tarball":"https://registry.npmjs.org/to-key/-/to-key-1.0.0.tgz","integrity":"sha512-jF2VJ/9Sh1UvhUU/Zgv4tcot18hpfVKy+6/9xyTHp5tSU9K5SkiUr62Oxb3RdVfRU8y9AbHr5iz2NJE9NQMloQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEduJyVhhL1Fw3zSCT6Auz0Yo5q5a2+OY6euzvlZ4G5KAiEAsmhWoYLejw4TkISzup15aJrzsc+va+acQ7G6aKQIy8g="}]}}},"readme":"# to-key [![NPM version](https://badge.fury.io/js/to-key.svg)](http://badge.fury.io/js/to-key)\n\n> Convert any value to a string that can be used as the key of an object.\n\n## Install with [npm](npmjs.org)\n\n```bash\nnpm i to-key --save\n```\n\n## Usage\n\n```js\nvar toKey = require('to-key');\n\ntoKey({foo: ['bar', {baz: {fex: 'fex'}}], one: 'two'});\n//=> 'foobarbazfexfexonetwo'\n```\n\nThis can be used for caching results when the results are predictable based on user input or other settings.\n\n**Example**\n\nWe'll assume that `someFn` in the example does some heavy processing on whatever arguments are passed that can be avoided if we can instead return the cached value of a previous call.\n\n```js\nvar cache = {};\nfunction myApp(one, two, three) {\n  var key = toKey([].slice.call(arguments));\n  if (cache.hasOwnProperty(key)) {\n    return cache[key];\n  }\n\n  var result = someFn(one, two, three);\n  cache[key] = result;\n  return result;\n}\n```\n\n**Why do this?**\n\nGiven the following:\n\n- `A` is time it takes (to-key or whatever you use) to stringify any arguments are passed\n- `B` is the amount of time it takes to retrieve a stored value from the cache \n- `C` is the time it takes your application to process arguments and store a new value on the cache\n\nIt's a good approach when `(A + B) < C`. In my applications. You can also use logic that conditionally uses cached results based on the complexity of the arguments passed. \n\n## Run tests\n\nInstall dev dependencies:\n\n```bash\nnpm i -d && npm test\n```\n\n## Contributing\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/to-key/issues)\n\n## Author\n\n**Jon Schlinkert**\n \n+ [github/jonschlinkert](https://github.com/jonschlinkert)\n+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) \n\n## License\nCopyright (c) 2015 Jon Schlinkert  \nReleased under the MIT license\n\n***\n\n_This file was generated by [verb](https://github.com/assemble/verb) on February 16, 2015._\n","maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"time":{"modified":"2022-06-27T07:23:46.289Z","created":"2015-02-17T04:58:49.254Z","1.0.0":"2015-02-17T04:58:49.254Z"},"homepage":"https://github.com/jonschlinkert/to-key","keywords":["cache","key","object","property","string","stringify","to","to-string","tostring"],"repository":{"type":"git","url":"git://github.com/jonschlinkert/to-key.git"},"author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"bugs":{"url":"https://github.com/jonschlinkert/to-key/issues"},"license":{"type":"MIT","url":"https://github.com/jonschlinkert/to-key/blob/master/LICENSE"},"readmeFilename":"README.md"}