{"id":21011050,"url":"https://github.com/featurist/lowscore","last_synced_at":"2025-05-15T03:32:08.217Z","repository":{"id":52142519,"uuid":"53396714","full_name":"featurist/lowscore","owner":"featurist","description":"a very small underscore, for browser apps that like to watch their weight","archived":false,"fork":false,"pushed_at":"2021-05-06T21:47:27.000Z","size":74,"stargazers_count":24,"open_issues_count":3,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-11T19:15:57.021Z","etag":null,"topics":["lite","underscore"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/featurist.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-08T08:47:00.000Z","updated_at":"2021-03-17T15:35:13.000Z","dependencies_parsed_at":"2022-08-31T17:01:58.616Z","dependency_job_id":null,"html_url":"https://github.com/featurist/lowscore","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/featurist%2Flowscore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/featurist%2Flowscore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/featurist%2Flowscore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/featurist%2Flowscore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/featurist","download_url":"https://codeload.github.com/featurist/lowscore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225325550,"owners_count":17456747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lite","underscore"],"created_at":"2024-11-19T09:25:23.571Z","updated_at":"2024-11-19T09:25:24.315Z","avatar_url":"https://github.com/featurist.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lowscore [![npm version](https://img.shields.io/npm/v/lowscore.svg)](https://www.npmjs.com/package/lowscore) [![npm](https://img.shields.io/npm/dm/lowscore.svg)](https://www.npmjs.com/package/lowscore)\n\nA very lightweight underscore, for browser apps that like to watch their weight.\n\nNote, this is a very incomplete implementation of underscore, partly because many of underscore's functions can be found on `Array` and `Object` now, and also partly because I'm lazy. Pull requests for missing functions will be accepted gladly.\n\n# API\n\nYou can either import all of lowscore, or just the parts you need.\n\n```js\nvar _ = require('lowscore');\n_.groupBy(...);\n_.indexBy(...);\n\nvar groupBy = require('lowscore/groupBy');\nvar indexBy = require('lowscore/indexBy');\n...\n```\n\n## find (87 bytes)\n\n| Module | Size (minified) |\n| --- | ---: |\n| `lowscore/find` | 87 |\n| `lodash.find` | 12681 |\n| `lodash/fp/find` | 61376 |\n| `underscore` (all) | 16133 |\n\n```js\nvar find = require('lowscore/find');\nvar found = find(list, predicate);\n```\n\nLooks through each value in the list, returning the first one that passes a truth test (predicate), or undefined if no value passes the test. The function returns as soon as it finds an acceptable element, and doesn't traverse the entire list.\n\n```js\nvar even = find([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });\n=\u003e 2\n```\n\n## findIndex (97 bytes)\n\n| Module | Size (minified) |\n| --- | ---: |\n| `lowscore/findIndex` | 97 |\n| `lodash.findindex` | 12509 |\n| `lodash/fp/findIndex` | 60952 |\n| `underscore` (all) | 16133 |\n\n```js\nvar findIndex = require('lowscore/findIndex');\nvar foundIndex = findIndex(list, predicate);\n```\n\nReturns the first index where the predicate truth test passes; otherwise returns -1. Predicate is passed the item and item index.\n\n```js\nfindIndex([4, 6, 8, 12], isPrime);\n=\u003e -1 // not found\nfindIndex([4, 6, 7, 12], isPrime);\n=\u003e 2\n```\n\n## sortBy (327 bytes)\n\n| Module | Size (minified) |\n| --- | ---: |\n| `lowscore/sortBy` | 327 |\n| `lodash.sortby` | 13990 |\n| `lodash/fp/sortBy` | 63749 |\n| `underscore` (all) | 16133 |\n\n```js\nvar sortBy = require('lowscore/sortBy');\nvar sorted = sortBy(list, iteratee);\n```\n\nReturns a (stably) sorted copy of list, ranked in ascending order by the results of running each value through iteratee. iteratee may also be the string name of the property to sort by (eg. length).\n\n```js\nsortBy([1, 2, 3, 4, 5, 6], function(num){ return Math.sin(num); });\n=\u003e [5, 4, 6, 3, 1, 2]\n\nvar stooges = [{name: 'moe', age: 40}, {name: 'larry', age: 50}, {name: 'curly', age: 60}];\nsortBy(stooges, 'name');\n=\u003e [{name: 'curly', age: 60}, {name: 'larry', age: 50}, {name: 'moe', age: 40}];\n```\n\n## groupBy (165 bytes)\n\n| Module | Size (minified) |\n| --- | ---: |\n| `lowscore/groupBy` | 165 |\n| `lodash.groupby` | 12392 |\n| `lodash/fp/groupBy` | 62274 |\n| `underscore` (all) | 16133 |\n\n```js\nvar groupBy = require('lowscore/groupBy');\nvar groups = groupBy(list, iteratee);\n```\n\nSplits a collection into sets, grouped by the result of running each value through iteratee. If iteratee is a string instead of a function, groups by the property named by iteratee on each of the values.\n\n```js\ngroupBy([1.3, 2.1, 2.4], function(num){ return Math.floor(num); });\n=\u003e {1: [1.3], 2: [2.1, 2.4]}\n\ngroupBy(['one', 'two', 'three'], 'length');\n=\u003e {3: [\"one\", \"two\"], 5: [\"three\"]}\n```\n\n## indexBy (144 bytes)\n\n| Module | Size (minified) |\n| --- | ---: |\n| `lowscore/indexBy` | 144 |\n| `lodash.indexby` | 10307 |\n| `lodash/fp/indexBy` | 62265 |\n| `underscore` (all) | 16133 |\n\n```js\nvar indexBy = require('lowscore/indexBy');\nvar index = indexBy(list, iteratee);\n```\n\nGiven a list, and an iteratee function that returns a key for each element in the list (or a property name), returns an object with an index of each item. Just like groupBy, but for when you know your keys are unique.\n\n```js\nvar stooges = [{name: 'moe', age: 40}, {name: 'larry', age: 50}, {name: 'curly', age: 60}];\nindexBy(stooges, 'age');\n=\u003e {\n  \"40\": {name: 'moe', age: 40},\n  \"50\": {name: 'larry', age: 50},\n  \"60\": {name: 'curly', age: 60}\n}\n```\n\n## pick (272 bytes)\n\n| Module | Size (minified) |\n| --- | ---: |\n| `lowscore/pick` | 272 |\n| `lodash.pick` | 2037 |\n| `lodash/fp/pick` | 61663 |\n| `underscore` (all) | 16133 |\n\n```js\nvar pick = require('lowscore/pick');\npick(object, key1, key2, ...);\npick(object, [key1, key2, ...]);\npick(object, function (value, key, object) { return key == key1; });\n```\n\nReturn a copy of the object, filtered to only have values for the whitelisted keys (or array of valid keys). Alternatively accepts a predicate indicating which keys to pick.\n\n```js\npick({name: 'moe', age: 50, userid: 'moe1'}, 'name', 'age');\n=\u003e {name: 'moe', age: 50}\npick({name: 'moe', age: 50, userid: 'moe1'}, function(value, key, object) {\n  return !isNaN(Number(value));\n});\n=\u003e {age: 50}\n```\n\n## omit (317 bytes)\n\n| Module | Size (minified) |\n| --- | ---: |\n| `lowscore/omit` | 317 |\n| `lodash.omit` | 6765 |\n| `lodash/fp/omit` | 62467 |\n| `underscore` (all) | 16133 |\n\n```js\nvar omit = require('lowscore/omit');\nomit(object, key1, key2, ...);\nomit(object, [key1, key2, ...]);\nomit(object, function (value, key, object) { return key == key1; });\n```\n\nReturn a copy of the object, filtered to omit the blacklisted keys (or array of keys). Alternatively accepts a predicate indicating which keys to omit.\n\n```js\nomit({name: 'moe', age: 50, userid: 'moe1'}, 'userid');\n=\u003e {name: 'moe', age: 50}\nomit({name: 'moe', age: 50, userid: 'moe1'}, function(value, key, object) {\n  return !isNaN(Number(value));\n});\n=\u003e {name: 'moe', userid: 'moe1'}\n```\n\n## mapObject (121 bytes)\n\n| Module | Size (minified) |\n| --- | ---: |\n| `lowscore/mapObject` | 121 |\n| `lodash.mapvalues` | 11991 |\n| `lodash/fp/mapValues` | 61328 |\n| `underscore` (all) | 16133 |\n\n```js\nvar mapObject = require('lowscore/mapObject');\nmapObject(object, iteratee);\n```\n\nLike map, but for objects. Transform the value of each property in turn.\n\n```js\nmapObject({start: 5, end: 12}, function(val, key, object) {\n  return val + 5;\n});\n=\u003e {start: 10, end: 17}\n```\n\n## object (158 bytes)\n\n| Module | Size (minified) |\n| --- | ---: |\n| `lowscore/object` | 158 |\n| `lodash.frompairs` | 75 |\n| `lodash/fp/fromPairs` | 60787 |\n| `underscore` (all) | 16133 |\n\n```js\nvar object = require('lowscore/object');\nobject(list, [values]);\n```\n\nConverts arrays into objects. Pass either a single list of `[key, value]` pairs, or a list of keys, and a list of values. If duplicate keys exist, the last value wins.\n\n```js\n_.object(['moe', 'larry', 'curly'], [30, 40, 50]);\n=\u003e {moe: 30, larry: 40, curly: 50}\n\n_.object([['moe', 30], ['larry', 40], ['curly', 50]]);\n=\u003e {moe: 30, larry: 40, curly: 50}\n```\n\n## flatten (161 bytes)\n\n| Module | Size (minified) |\n| --- | ---: |\n| `lowscore/flatten` | 161 |\n| `lodash.flatten` | 1203 |\n| `lodash/fp/flatten` | 60775 |\n| `underscore` (all) | 16133 |\n\n```js\nvar flatten = require('lowscore/flatten');\nvar r = flatten(array, [shallow]);\n```\n\nFlattens a nested array (the nesting can be to any depth). If you pass shallow, the array will only be flattened a single level.\n\n```js\nflatten([1, [2], [3, [[4]]]]);\n=\u003e [1, 2, 3, 4];\n\nflatten([1, [2], [3, [[4]]]], true);\n=\u003e [1, 2, 3, [[4]]];\n```\n\n## max (209 bytes)\n\n| Module | Size (minified) |\n| --- | ---: |\n| `lowscore/max` | 209 |\n| `lodash.max` | 373 |\n| `lodash/fp/max` | 61244 |\n| `underscore` (all) | 16133 |\n\n```js\nvar max = require('lowscore/max');\nvar smallestItem = max(items, [iteratee]);\n```\n\nReturns the maximum value in list. If an iteratee function is provided, it will be used on each value to generate the criterion by which the value is ranked. -Infinity is returned if list is empty, so an isEmpty guard may be required. Non-numerical values in list will be ignored.\n\n```js\nvar stooges = [{name: 'moe', age: 40}, {name: 'larry', age: 50}, {name: 'curly', age: 60}];\n_.max(stooges, function(stooge){ return stooge.age; });\n=\u003e {name: 'curly', age: 60};\n```\n\n## min (206 bytes)\n\n| Module | Size (minified) |\n| --- | ---: |\n| `lowscore/min` | 206 |\n| `lodash.min` | 373 |\n| `lodash/fp/min` | 61244 |\n| `underscore` (all) | 16133 |\n\n```js\nvar min = require('lowscore/min');\nvar smallestItem = min(items, [iteratee]);\n```\n\nReturns the minimum value in list. If an iteratee function is provided, it will be used on each value to generate the criterion by which the value is ranked. Infinity is returned if list is empty, so an isEmpty guard may be required. Non-numerical values in list will be ignored.\n\n```js\nvar numbers = [10, 5, 100, 2, 1000];\n_.min(numbers);\n=\u003e 2\n```\n\n## compact (67 bytes)\n\n| Module | Size (minified) |\n| --- | ---: |\n| `lowscore/compact` | 67 |\n| `lodash.compact` | 78 |\n| `lodash/fp/compact` | 60912 |\n| `underscore` (all) | 16133 |\n\n```js\nvar compact = require('lowscore/compact');\nvar a = compact(array);\n```\n\nReturns a copy of the array with all falsy values removed. In JavaScript, false, null, 0, \"\", undefined and NaN are all falsy.\n\n```js\ncompact([0, 1, false, 2, '', 3]);\n=\u003e [1, 2, 3]\n```\n\n## without (135 bytes)\n\n| Module | Size (minified) |\n| --- | ---: |\n| `lowscore/without` | 135 |\n| `lodash.without` | 4888 |\n| `lodash/fp/without` | 61951 |\n| `underscore` (all) | 16133 |\n\n```js\nvar without = require('lowscore/without');\nvar a = without(array, *values);\n```\n\nReturns a copy of the array with all instances of the values removed.\n\n```js\nwithout([1, 2, 1, 0, 3, 1, 4], 0, 1);\n=\u003e [2, 3, 4]\n```\n\n## range (224 bytes)\n\n| Module | Size (minified) |\n| --- | ---: |\n| `lowscore/range` | 224 |\n| `lodash.range` | 1505 |\n| `lodash/fp/range` | 61527 |\n| `underscore` (all) | 16133 |\n\n```js\nvar range = require('lowscore/range');\nvar r = range([start], stop, [step]);\n```\n\nA function to create flexibly-numbered lists of integers, handy for each and map loops. start, if omitted, defaults to 0; step defaults to 1. Returns a list of integers from start (inclusive) to stop (exclusive), incremented (or decremented) by step, exclusive. Note that ranges that stop before they start are considered to be zero-length instead of negative — if you'd like a negative range, use a negative step.\n\n```js\nrange(10);\n=\u003e [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\nrange(1, 11);\n=\u003e [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\nrange(0, 30, 5);\n=\u003e [0, 5, 10, 15, 20, 25]\nrange(0, -10, -1);\n=\u003e [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]\nrange(0);\n=\u003e []\n```\n\n## repeat (115 bytes)\n\n```js\nrepeat(3, 'stuff')\n=\u003e ['stuff', 'stuff', 'stuff']\n```\n\n## extend (142 bytes)\n\n| Module | Size (minified) |\n| --- | ---: |\n| `lowscore/extend` | 142 |\n| `lodash.assign` | 2378 |\n| `lodash/fp/assign` | 61936 |\n| `underscore` (all) | 16133 |\n\n```js\nvar extend = require('lowscore/extend');\nvar destination = extend(destination, *sources);\n```\n\nCopy all of the properties in the source objects over to the destination object, and return the destination object. It's in-order, so the last source will override properties of the same name in previous arguments.\n\n```js\nextend({name: 'moe'}, {age: 50});\n=\u003e {name: 'moe', age: 50}\n```\n\n## times (77 bytes)\n\n| Module | Size (minified) |\n| --- | ---: |\n| `lowscore/times` | 77 |\n| `lodash.times` | 1013 |\n| `lodash/fp/times` | 61076 |\n| `underscore` (all) | 16133 |\n\n```js\nvar times = require('lowscore/times');\nvar t = times(n, iteratee);\n```\n\nInvokes the given iteratee function n times. Each invocation of iteratee is called with an index argument. Produces an array of the returned values. \n\n```js\ntimes(3, function(n){ return \"item: \" + n; });\n=\u003e ['item: 0', 'item: 1', 'item: 2']\n```\n\n## values (80 bytes)\n\n| Module | Size (minified) |\n| --- | ---: |\n| `lowscore/values` | 80 |\n| `lodash.values` | 1391 |\n| `lodash/fp/values` | 61053 |\n| `underscore` (all) | 16133 |\n\n```js\nvar values = require('lowscore/values');\nvar t = values(n, iteratee);\n```\n\nReturn all of the values of the object's own properties.\n\n```js\nvalues({one: 1, two: 2, three: 3});\n=\u003e [1, 2, 3]\n```\n\n## uniq (199 bytes)\n\n| Module | Size (minified) |\n| --- | ---: |\n| `lowscore/uniq` | 199 |\n| `lodash.uniq` | 4357 |\n| `lodash/fp/uniq` | 61855 |\n| `underscore` (all) | 16133 |\n\n```js\nvar uniq = require('lowscore/uniq');\nvar t = uniq(array, [iteratee]);\n```\n\nRemove duplicate entries from the array. If iteratee is given then the entries uniqueness is based on the result returned by the iteratee. If iteratee is a string instead of a function, uniqueness is based on the property named by iteratee on each of the values.\n\n```js\nuniq([1, 2, 2, 3, 1, 2]);\n=\u003e [1, 2, 3]\n```\n\n## zip (230 bytes)\n\n| Module | Size (minified) |\n| --- | ---: |\n| `lowscore/zip` | 230 |\n| `lodash.zip` | 1272 |\n| `lodash/fp/zip` | 61514 |\n| `underscore` (all) | 16133 |\n\n```js\nvar zip = require('lowscore/zip');\nvar zipped = zip(...arrays);\n```\n\nMerges together the values of each of the arrays with the values at the corresponding position. Useful when you have separate data sources that are coordinated through matching array indexes. Use with apply to pass in an array of arrays. If you're working with a matrix of nested arrays, this can be used to transpose the matrix.\n\n```js\nzip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]);\n=\u003e [[\"moe\", 30, true], [\"larry\", 40, false], [\"curly\", 50, false]]\n```\n\n## We're Hiring!\n\nJoin our remote team and help us build amazing software. Check out [our career opportunities](https://www.featurist.co.uk/careers/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeaturist%2Flowscore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffeaturist%2Flowscore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeaturist%2Flowscore/lists"}