{"_id":"to-key","_rev":"32993","name":"to-key","description":"Stringify any value to be used as the key of an object.","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"time":{"modified":"2021-06-03T10:05:58.000Z","created":"2015-02-17T04:58:49.254Z","1.0.0":"2015-02-17T04:58:49.254Z"},"users":{},"author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git://github.com/jonschlinkert/to-key.git"},"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","size":2591,"noattachment":false,"key":"/to-key/-/to-key-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/to-key/download/to-key-1.0.0.tgz"},"directories":{},"publish_time":1424149129254,"_cnpm_publish_time":1424149129254,"_hasShrinkwrap":false}},"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","_attachments":{},"homepage":"https://github.com/jonschlinkert/to-key","bugs":{"url":"https://github.com/jonschlinkert/to-key/issues"},"license":{"type":"MIT","url":"https://github.com/jonschlinkert/to-key/blob/master/LICENSE"}}