{"_id":"dank-map","_rev":"5-6ae06740b6e6ecd73a97c668fdb266c2","name":"dank-map","description":"A map function that can map over almost anything.","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"dank-map","version":"0.1.0","description":"A map function that can map over almost anything.","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"https://github.com/wankdanker/node-dank-map.git"},"keywords":["map","attribute","key","index","array"],"author":{"name":"Dan VerWeire"},"license":"MIT","readme":"dank-map\n--------\n\nExecute a function `fn` for each `key` or `index` in `obj`. \nValues returned from `fn` are appended to an array which is \nreturned by the map function.\n\napi\n---\n\nmap(obj, fn, squash);\n\n* _obj_ - the object for which `fn` will be called for each `key` or `index`.\n\tThis can be an Array, Object, String, Number or whatever.\n* _fn_  - callback function which is called for each `key` or `index`.\n\tReview the callback function section below.\n* _squash_ - when true, don't push undefined or null values on to the final\n\tarray.\n\nthe callback\n------------\n\nWhen `fn` is called it is passed the following arguments:\n\n* _key_ - the `key`, `index`, or attribute name from the object which is being\n\tmapped.\n* _value_ - the value of the current key, index or attribute.\n* _emit_ *function* - call this `function` passing it a value to explicitly push\n\ta new value onto the final array.\n* _end_ *function* - call this `function` to stop iterating over `obj`.\n\nAny value returned from the callback function will be appended to the final array.\nThe only excpetion to this would be if `sqash` is set to true in which case any\nundefined or null return value would NOT be appended to the final array.\n\nexample\n-------\n\n```javascript\na = [40,50,2,1];\n\nb = map(a, function (key, val, emit, end) {\n     //key is the index in the array\n\n     if (val > 10) {\n             return val; \n     }\n});\n\n// b = [40, 50, null, null];\n\n//this time we will sqash falsy values\nc = map(a, function (key, val, emit, end) {\n     //key is the index in the array\n\n     if (val > 10) {\n             return val; \n     }\n}, true); //turn on squash\n\n// c = [40, 50]; \n\n//map over an object;\n\nd = { customer_id : 1, name : 'Willy Wonka' };\n\ne = map(d, function (key, val, emit, end) {\n\temit(val);\n\n\treturn key;\n});\n\n//e = [1, 'customer_id', 'Willy Wonka', 'name'];\n```\n\nThese examples aren't that great. I typically use this function\nto map over arrays of objects that come from a database query.\n\nlicense\n----------\n\n### The MIT License (MIT)\n\n\nCopyright (c) 2012 Daniel L. VerWeire\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","_id":"dank-map@0.1.0","dist":{"shasum":"e99e77f382c68f2e5ab2b3f3a82b8031957529a8","tarball":"https://registry.npmjs.org/dank-map/-/dank-map-0.1.0.tgz","integrity":"sha512-mQoLySkWc5bQM8XKXz0rIuISX/+12rSSfPojYlTVT6KPj3LsvfLURtrv0w+QEt1gRIKwp9mxnwOcL5nsOTkk2Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCNY6fllZfuLztDAAuoVP3CsXOK9dkuLdh3pX2/FGYm0QIhAIZx+69De1v6mrczw6i76SF+iXxDHJ1CGQL0pHf9cY7T"}]},"_npmVersion":"1.1.59","_npmUser":{"name":"wankdanker","email":"dverweire@gmail.com"},"maintainers":[{"name":"wankdanker","email":"dverweire@gmail.com"}]}},"readme":"dank-map\n--------\n\nExecute a function `fn` for each `key` or `index` in `obj`. \nValues returned from `fn` are appended to an array which is \nreturned by the map function.\n\napi\n---\n\nmap(obj, fn, squash);\n\n* _obj_ - the object for which `fn` will be called for each `key` or `index`.\n\tThis can be an Array, Object, String, Number or whatever.\n* _fn_  - callback function which is called for each `key` or `index`.\n\tReview the callback function section below.\n* _squash_ - when true, don't push undefined or null values on to the final\n\tarray.\n\nthe callback\n------------\n\nWhen `fn` is called it is passed the following arguments:\n\n* _key_ - the `key`, `index`, or attribute name from the object which is being\n\tmapped.\n* _value_ - the value of the current key, index or attribute.\n* _emit_ *function* - call this `function` passing it a value to explicitly push\n\ta new value onto the final array.\n* _end_ *function* - call this `function` to stop iterating over `obj`.\n\nAny value returned from the callback function will be appended to the final array.\nThe only excpetion to this would be if `sqash` is set to true in which case any\nundefined or null return value would NOT be appended to the final array.\n\nexample\n-------\n\n```javascript\na = [40,50,2,1];\n\nb = map(a, function (key, val, emit, end) {\n     //key is the index in the array\n\n     if (val > 10) {\n             return val; \n     }\n});\n\n// b = [40, 50, null, null];\n\n//this time we will sqash falsy values\nc = map(a, function (key, val, emit, end) {\n     //key is the index in the array\n\n     if (val > 10) {\n             return val; \n     }\n}, true); //turn on squash\n\n// c = [40, 50]; \n\n//map over an object;\n\nd = { customer_id : 1, name : 'Willy Wonka' };\n\ne = map(d, function (key, val, emit, end) {\n\temit(val);\n\n\treturn key;\n});\n\n//e = [1, 'customer_id', 'Willy Wonka', 'name'];\n```\n\nThese examples aren't that great. I typically use this function\nto map over arrays of objects that come from a database query.\n\nlicense\n----------\n\n### The MIT License (MIT)\n\n\nCopyright (c) 2012 Daniel L. VerWeire\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","maintainers":[{"name":"wankdanker","email":"dverweire@gmail.com"}],"time":{"modified":"2022-06-14T18:15:35.327Z","created":"2012-09-20T18:49:57.837Z","0.1.0":"2012-09-20T18:49:59.651Z"},"author":{"name":"Dan VerWeire"},"repository":{"type":"git","url":"https://github.com/wankdanker/node-dank-map.git"}}