{"_id":"@bopepsi/lotide","_rev":"4-6b91509aa569d2320a9713725771d1d1","time":{"created":"2022-05-09T20:24:41.439Z","1.0.0":"2022-05-09T20:14:47.432Z","modified":"2022-05-09T20:27:21.330Z","1.0.1":"2022-05-09T20:24:41.662Z","1.0.2":"2022-05-09T20:27:21.262Z"},"name":"@bopepsi/lotide","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.1":{"name":"@bopepsi/lotide","version":"1.0.1","description":"A mini clone of the [Lodash](https://lodash.com) library.","main":"assertArraysEqual.js","directories":{"test":"test"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git+https://github.com/bopepsi/lotide.git"},"keywords":["lodash","array","object"],"author":"","license":"BSD-3-Clause","bugs":{"url":"https://github.com/bopepsi/lotide/issues","email":"bopepsi@gmail.com"},"homepage":"https://github.com/bopepsi/lotide#readme","devDependencies":{"chai":"^4.3.6","mocha":"^10.0.0"},"people":{"name":"Bowen J","email":"bopepsi@gmail.com","url":"https://github.com/bopepsi/lotide/"},"gitHead":"e271cd679847b949c7c7103856cb38a5ecd19824","_id":"@bopepsi/lotide@1.0.1","_nodeVersion":"16.14.0","_npmVersion":"8.3.1","dist":{"integrity":"sha512-5nHKTbcvJmpfoMbUdR1h7q8IMhvzxZp5bspeIZ8i0EzkHrkkGDY/zgVv0ETNCGkucDdd5TUkYH9S3XDGVTsuBw==","shasum":"1cf599269591b2e356f8ced152fc6acd9ef84401","tarball":"https://registry.npmjs.org/@bopepsi/lotide/-/lotide-1.0.1.tgz","fileCount":26,"unpackedSize":20840,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCofW8sOloREhZ294f0bwpamARWBhLKA+v0ofYDNFMGrAIgZI2pPG6igSrmfG71s/G8kswvxdBCRMO2WV0d1kzE6kI="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJieXiJACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpgjQ/+ONVHGuloWMn/d6aEfxE1pJU0MAf/j96x34wIBuVOK7NtIloI\r\ngoPMDtjkyF9xmdtGp0sQXSbol6gH8KHQLrLqGD3xV/ufbIdU6ySe7iClJkfh\r\n3Gt5B9c0/woKO0c16FfXDPxQnkmfbmOkKTmXSLSfT0pFr+/wpJfLF5l1p05w\r\ngQgtjzDX7HdQyuYlXhYUesTmrX4aHoKeRVN12NhPe+BaWAaqGLdFPCG46ll4\r\nnqxX9J0rbcFQOTZRU4hHyXF0lFQK1rsVqBsJDwNUfFvnOZiGXCwdK8EHUqWH\r\niFyFfo0RWeiNHY5DztxG0zadktlOQ60bYM9NnnECVLjHpbhYkZn/hyEatyR5\r\nM8NemRWsVOAwvjRMVnHJXBkL+2ye/bS9AAiosr2jOMvNIOWuejG4Hj7WPoR7\r\nE3xDtFVp3urE7W6HYB3g+BEuo+iHtVjNxzBjjggH3E2QALIoJ9Wiwf7LE1lH\r\nUFXRMfL41S3foTgb7oVEstBnMGbr1qb/apcFi4aSf2J8q0zBC1OUouU4PMbj\r\nNnQURkfc8yUjpeE5r0rxfREScGTKZh9LpSvylNs/AvgeF/tqsxon+WXdyAYb\r\nYALKiCciTmNCapBVZ90ucxb6gkcJOjQN71GiK/SkAWFVtfrj+pCZCpB2Kq+3\r\n0QJdyOw3ZJh1EHAWVhCfwkoyq/dMM4HeDM0=\r\n=SkOq\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"bopepsi","email":"bopepsi@gmail.com"},"maintainers":[{"name":"bopepsi","email":"bopepsi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lotide_1.0.1_1652127881516_0.9916826509888486"},"_hasShrinkwrap":false},"1.0.2":{"name":"@bopepsi/lotide","version":"1.0.2","description":"A mini clone of the [Lodash](https://lodash.com) library.","main":"assertArraysEqual.js","directories":{"test":"test"},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git+https://github.com/bopepsi/lotide.git"},"keywords":["lodash","array","object"],"author":"","license":"BSD-3-Clause","bugs":{"url":"https://github.com/bopepsi/lotide/issues","email":"bopepsi@gmail.com"},"homepage":"https://github.com/bopepsi/lotide#readme","devDependencies":{"chai":"^4.3.6","mocha":"^10.0.0"},"people":{"name":"Bowen J","email":"bopepsi@gmail.com","url":"https://github.com/bopepsi/lotide/"},"gitHead":"e271cd679847b949c7c7103856cb38a5ecd19824","_id":"@bopepsi/lotide@1.0.2","_nodeVersion":"16.14.0","_npmVersion":"8.3.1","dist":{"integrity":"sha512-7MJuu9aCDZ2/7zY5JqtQ7I7bQ3IMxbTG8mBWj/wLpSNV9JSt3+OFgjrVqBzaxeAcYiaXuoaeGXAYibTi+ECHfQ==","shasum":"f1233eb29e6035c634ef1757a5f129040283478d","tarball":"https://registry.npmjs.org/@bopepsi/lotide/-/lotide-1.0.2.tgz","fileCount":26,"unpackedSize":20433,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID2Mi+1u8vLYz/7pH++HWCy7egFZg6lffbeisrUsKGwfAiEA5B7FTL3eXmrEWKswIyVpPKL3LdE59VJZekhZ9fYEALk="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJieXkpACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpp5w/+LkVoQ4ACaWhOJTWOVakUlMsbT/+b5FJp3AO0dOtuIjPJWw0u\r\nViCMxJpcPlOSj+pgcwv8bCDkzKAW0VjCAt87YLIMJxhwmofVsQHIXOyY9bys\r\nkCx+PplaJhI+YFVuYIK1ftxaxjnj9aHIuBClGNqUSqt9Mb0FTKkDX+pzby7k\r\nz/5x5baRg4KB9k9JTHw3CNytwJ/bSF+XHPIQxfpoFKkGXe0BlKcTwH8zbKSz\r\n/vWCWGaA/1Qp9gqEJ02uUvYRP2x7+0jPRd63KgEkiVg3PVDSonATpkcL8nuT\r\nDbmpL1h345dzUybN3GmvOPTxAQCxmvWRXjuuPcADRkcpJxfpvSOtjvKkESnK\r\nZ5QTZ8AW72SX6MaVfLwYlKM53v1wB7RYN+zW9QPEyoQxdGuQRiEfbN2kp2Dk\r\n2b2VsyJzL/lrQbYhkVX6MkTAZggRwzhyZKWg3JUbqCaYCWnM28yWtgRYbMz9\r\nK9/8I8HyA16vbIQ675jkSh/tHhGw3AUwjPTS8LaSHKSdN/fwcFpAvw9EDxFE\r\nAEZHbII81M0WcR0O93BbGdRSRrZUBSBMwf35JmWSQuBirV/ns4QBNZSziswz\r\nFXO5Tw4lY1WKS23qyODBxjJ9eu6zk4CtfuJOFSQehspmIXNNlrWOzStycmrb\r\n+7dFL+xCZ76S0jYB55ZqQB1zETEZ4dBIyTk=\r\n=kPJ5\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"bopepsi","email":"bopepsi@gmail.com"},"maintainers":[{"name":"bopepsi","email":"bopepsi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lotide_1.0.2_1652128041140_0.7535277706959058"},"_hasShrinkwrap":false}},"maintainers":[{"name":"bopepsi","email":"bopepsi@gmail.com"}],"description":"A mini clone of the [Lodash](https://lodash.com) library.","homepage":"https://github.com/bopepsi/lotide#readme","keywords":["lodash","array","object"],"repository":{"type":"git","url":"git+https://github.com/bopepsi/lotide.git"},"bugs":{"url":"https://github.com/bopepsi/lotide/issues","email":"bopepsi@gmail.com"},"license":"BSD-3-Clause","readme":"# Lotide\n\nA mini clone of the [Lodash](https://lodash.com) library.\n\n## Purpose\n\n**_BEWARE:_ This library was published for learning purposes. It is _not_ intended for use in production-grade software.**\n\nThis project was created and published by me as part of my learnings at Lighthouse Labs. \n\n## Usage\n\n**Install it:**\n\n`npm install @bopepsi/lotide`\n\n**Require it:**\n\n`const _ = require('@bopepsi/lotide');`\n\n**Call it:**\n\n`const results = _.tail([1, 2, 3]) // => [2, 3]`\n\n## Documentation\n\nThe following functions are currently implemented:\n```js\nconst assertArraysEqual = function (actual, expected) {\n    let ans = true;\n    const helper = (arr1, arr2) => {\n        if (arr1.length !== arr2.length) ans = false;\n        for (var i = 0; i < arr1.length; i++) {\n            if (Array.isArray(arr1[i])) helper(arr1[i], arr2[i]);\n            else { if (arr1[i] !== arr2[i]) ans = false; }\n        };\n    }\n    helper(actual, expected);\n    if (ans) {\n        console.log(`✅✅✅ Assertion Passed: ${actual} === ${expected}`);\n        return true;\n    }\n    if (!ans) {\n        console.log(`🔴🔴🔴 Assertion Failed: ${actual} !== ${expected}`);\n        return false;\n    }\n};\n\nconst assertEqual = function (actual, expected) {\n    if (actual === expected) console.log(`✅✅✅ Assertion Passed: ${actual} === ${expected}`);\n    else console.log(`🔴🔴🔴 Assertion Failed: ${actual} !== ${expected}`);\n    return actual === expected;\n};\n\n\nconst assertObjectsEqual = (actual, expected) => {\n    const inspect = require('util').inspect;\n    if (Object.keys(actual).length !== Object.keys(expected).length) {\n        console.log(`🔴🔴🔴 Assertion Failed: ${inspect(actual)} !== ${inspect(expected)}`);\n        return false;\n    }\n    for (var key in actual) {\n        let expectedVal = expected[key];\n        if (Array.isArray(actual[key])) {\n            console.log('checking array')\n            if (actual[key].length !== expectedVal.length) {\n                console.log(`🔴🔴🔴 Assertion Failed: ${inspect(actual)} !== ${inspect(expected)}`);\n                return false;\n            }\n            for (var i = 0; i < actual[key].length; i++) {\n                if (actual[key][i] !== expectedVal[i]) {\n                    console.log(`🔴🔴🔴 Assertion Failed: ${inspect(actual)} !== ${inspect(expected)}`);\n                    return false;\n                }\n            }\n            continue;\n        }\n        if (typeof actual[key] !== 'object') {\n            console.log('checking primitive vals')\n            if (actual[key] !== expectedVal) {\n                console.log(`🔴🔴🔴 Assertion Failed: ${inspect(actual)} !== ${inspect(expected)}`);\n                return false;\n            }\n        } else {\n            console.log('checking obj')\n            return assertObjectsEqual(actual[key], expectedVal);\n        }\n    } console.log(`✅✅✅ Assertion Passed: ${inspect(actual)} === ${inspect(expected)}`);\n\n    return true;\n};\n\nconst countLetters = str => {\n    let ans = {};\n    for (var char of str.replace(' ', '')) {\n        ans[char] = (ans[char] || 0) + 1;\n    }\n    return ans;\n};\n\nconst countOnly = function (allItems, itemsToCount) {\n    let temp = {};\n    for (var item of allItems) {\n        if (itemsToCount[item]) temp[item] = (temp[item] || 0) + 1;\n    };\n    return temp;\n};\n\nconst eqArrays = function (actual, expected) {\n    let ans = true;\n    const helper = (arr1, arr2) => {\n        if (arr1.length !== arr2.length) ans = false;\n        for (var i = 0; i < arr1.length; i++) {\n            if (Array.isArray(arr1[i])) helper(arr1[i], arr2[i]);\n            else { if (arr1[i] !== arr2[i]) ans = false; }\n        };\n    }\n    helper(actual, expected);\n    return ans;\n};\n\nconst eqObjects = (obj1, obj2) => {\n    if (Object.keys(obj1).length !== Object.keys(obj2).length) return false;\n    for (var key in obj1) {\n        let obj2Val = obj2[key];\n        if (Array.isArray(obj1[key])) {\n            console.log('checking array')\n            if (obj1[key].length !== obj2Val.length) return false;\n            for (var i = 0; i < obj1[key].length; i++) {\n                if (obj1[key][i] !== obj2Val[i]) return false;\n            }\n            continue;\n        }\n        if (typeof obj1[key] !== 'object') {\n            console.log('checking primitive vals')\n            if (obj1[key] !== obj2Val) return false;\n        } else {\n            console.log('checking obj')\n            return eqObjects(obj1[key], obj2Val);\n        }\n    }\n    return true;\n};\n\nconst findKey = (obj, match) => {\n    for (var key in obj)\n        if (match(obj[key])) return key;\n};\n\nconst findKeyByValue = (obj, str) => {\n    for (let key in obj) {\n        if(obj[key]===str) return key;\n    }\n    return;\n};\n\nconst flatten = arr => {\n    let ans = [];\n    for (var item of arr) {\n        if (item.length) ans = ans.concat(flatten(item));\n        else ans.push(item);\n    }\n    return ans;\n};\n\nconst head = arr => arr ? arr[0] : undefined;\n\nconst letterPositions = (sentence = sentence.replace(' ', '')) => {\n    const results = {};\n    for (var i = 0; i < sentence.length; i++) {\n        if (results[sentence[i]]) results[sentence[i]].push(i);\n        else results[sentence[i]] = [i];\n    }\n    return results;\n};\n\nconst map = (arr, transform) => {\n    const results = [];\n    arr.forEach(item => results.push(transform(item)));\n    return results;\n};\n\nconst middle = array => {\n    if (array.length < 2) return [];\n    if (array.length % 2 !== 0) return array.slice(array.length / 2, array.length / 2 + 1);\n    else return array.slice(Math.floor(array.length / 2-1), Math.ceil(array.length / 2+1));\n};\n\nconst tail = arr => {\n    if (arr.length === 1) return [];\n    let result = [...arr].slice(1);\n    arr.slice()\n    return result;\n};\n\nconst takeUntil = function (array, callback) {\n    let results = [];\n    for (var element of array) {\n        if (!callback(element)) results.push(element);\n        if(callback(element)) break;\n    }\n    return results;\n};\n\nconst without = (words, filter) => {\n    let length = words.length;\n    for (var i = 0; i < length; i++) {\n        if (filter.includes(words[i])) {\n            words.splice(i, 1);\n            i--;\n            length = words.length;\n        }\n    }\n};\n```","readmeFilename":"README.md"}