{"id":13394142,"url":"https://github.com/nanoutils/nanoutils","last_synced_at":"2025-03-13T20:31:23.849Z","repository":{"id":39498751,"uuid":"122664420","full_name":"nanoutils/nanoutils","owner":"nanoutils","description":"🌊 Tiniest FP-friendly JavaScript utils library","archived":true,"fork":false,"pushed_at":"2023-04-24T08:37:06.000Z","size":3332,"stargazers_count":215,"open_issues_count":19,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-08T10:11:24.757Z","etag":null,"topics":["hacktoberfest","javascript","js","module","nano","nanoutils","treeshaking","utilities"],"latest_commit_sha":null,"homepage":"https://nanoutils.github.io/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nanoutils.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-02-23T19:33:53.000Z","updated_at":"2024-11-06T14:17:32.000Z","dependencies_parsed_at":"2024-01-13T17:11:20.556Z","dependency_job_id":"43040145-6abd-477a-8eed-4a40b9f1662a","html_url":"https://github.com/nanoutils/nanoutils","commit_stats":{"total_commits":746,"total_committers":10,"mean_commits":74.6,"dds":0.6246648793565683,"last_synced_commit":"93b00cf4432de345e5309dc260dfe31608c73142"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanoutils%2Fnanoutils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanoutils%2Fnanoutils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanoutils%2Fnanoutils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanoutils%2Fnanoutils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nanoutils","download_url":"https://codeload.github.com/nanoutils/nanoutils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243478068,"owners_count":20297187,"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":["hacktoberfest","javascript","js","module","nano","nanoutils","treeshaking","utilities"],"created_at":"2024-07-30T17:01:10.312Z","updated_at":"2025-03-13T20:31:23.196Z","avatar_url":"https://github.com/nanoutils.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# nanoutils\n\n[![npm version](https://badge.fury.io/js/nanoutils.svg)](https://badge.fury.io/js/nanoutils)\n[![npm download](https://img.shields.io/npm/dm/nanoutils.svg)](https://npmcharts.com/compare/nanoutils?minimal=true)\n[![npm download](https://img.shields.io/badge/telegram-join-blue.svg)](https://tele.gg/joinchat/BcQiRFh-eUXs8pbHBj-y5g)\n\nTiniest JavaScript utils library\n\n## Usage\n\nFirst, install `nanoutils`:\n\n```bash\n$ npm install --save nanoutils\n```\n\nor install it with `yarn`:\n\n```bash\n$ yarn add nanoutils\n```\n\nTo use ES modules we wrote a plugin [`babel-plugin-nanoutils`](https://github.com/nanoutils/babel-plugin-nanoutils)\n\nTo install:\n\n```bash\n$ npm install --save-dev babel-plugin-nanoutils\n```\n\nor\n\n```bash\n$ yarn add --dev babel-plugin-nanoutils\n```\n\nUsing `.babelrc`:\n\n```diff\n{\n  \"preset\": [\"env\"]\n+ \"plugins\": [\"nanoutils\"]\n}\n```\n\nvia CLI:\n\n```diff\n{\n  \"scripts\": {\n+   \"babel\": \"babel --plugins nanoutils app.js\",\n    \"test\": \"jest \u0026\u0026 eslint .\"\n  }\n}\n```\n\nor with Node API:\n\n```diff\nconst babel = require('babel-core')\n\nbabel.transform('code', {\n+ plugins: ['nanoutils']\n})\n```\n\n## Examples\n\n### Sort array of values by name alphabetically or by age\n\n```js\nimport { ascend, az, prop, sortBy } from \"nanoutils\";\n\nconst sortByName = sortBy(az(prop(\"name\")));\nconst sortByAge = sortBy(ascend(prop(\"age\")));\n\nconst consultants = [\n  { name: \"Mike\", age: 30 },\n  { name: \"David\", age: 35 },\n  { name: \"Alex\", age: 25 },\n];\n\nsortByName(consultants); // [{ name: 'Alex', age: 25 }, { name: 'David', age: 35 }, { name: 'Mike', age: 30 }]\nsortByAge(consultants); // [{ name: 'Alex', age: 25 }, { name: 'Mike', age: 30 }, { name: 'David', age: 35 }]\n```\n\n### Find sum of all ages which will be even next year\n\n```js\nimport { add, filterT, mapT, pipeT, prop, transduce } from \"nanoutils\";\n\nconst isEven = (value) =\u003e value % 2 === 0;\n\nconst sumOfAllEvenAgesNextYear = (array) =\u003e\n  transduce(\n    pipeT(mapT(prop(\"age\")), mapT(add(1)), filterT(isEven)),\n    add,\n    0,\n    array\n  );\n\nconst consultants = [\n  { name: \"Mike\", age: 30 },\n  { name: \"David\", age: 35 },\n  { name: \"Alex\", age: 25 },\n];\n\nsumOfAllEvenAgesNextYear(ages); // 62\n```\n\n### Return memoized mean\n\n```js\nimport { ascend, identity, join, mean, memoizeWith, sort } from \"nanoutils\";\n\nconst getHash = pipe(\n  sort(ascend(identity)),\n  join(\"-\")\n);\nconst memoizedMean = memoizeWith(getHash, mean);\n\nmemoizedMean([1, 2, 3]); // 2\nmemoizedMean([1, 2, 3]); // 2 (extracts from memoizeWith function with hash='1-2-3')\nmemoizedMean([3, 1, 2]); // 2 (extracts from memoizeWith function with hash='1-2-3')\n```\n\n## Inspiration\n\nWe support nano-hype in JavaScript and want to create as much nano-things as possible.  \nSo we're starting a challenge - write Ramda clone where no one method will be over 1KB size.  \nMore nano's for the God of nano's!\n\n## Basic ideas\n\n- **Functional style**. FP is cool, isn't it? :sunglasses: So we'll add some Ramda methods too.\n- **No ES6 features**. We don't use Babel to save support in older browsers and save a status of nano-library.\n- Use **methods composition** only if it won't greatly increase the size of method\n\n## Can I use it in my project?\n\nIt's production-ready but still has following drawbacks:\n\n- No TS types\n\nIt's also a Ramda-supportive, you can see both docs and types here: [Ramda docs](https://ramdajs.com/docs/)\n\n## Roadmap\n\n- [x] Create methods list\n- [x] Complete all needed methods (we get list of methods from Ramda) with 100% tests and types coverage\n- [x] Add documentation for all methods\n- [ ] Create a tool to split nanoutils to separated packages\n- [ ] Cover all methods with performance tests\n- [ ] Reduce methods sizes even more\n- [ ] Compare to `lodash`, `underscore` (?)\n\n## NPM scripts\n\nIf you want to help, here are some tools for you.\n\n### Shortcut for new methods\n\n```\nnpm run method:add \u003c...methods\u003e -- [flags]\nyarn method:add \u003c...methods\u003e -- [flags]\n\nParams:\n    methods           List with method names (separated by space)\n\nFlags:\n    -f                Overwrite methods (if exists)\n    --curried         Add curried method\n                      you can use --curried=\u003cN\u003e to add curryN\n    --types           Add index.d.ts for method typings\n    --perf            Add \u003cmethod\u003e.performance.js for performance test of method\n```\n\nIt will create `lib/method` dir with following files:\n\n```\nindex.js                File with method\nindex.d.ts              TypeScript typings (if --types passed)\nmethod.test.js          Test for method (I use Jest)\nmethod.performance.js   Performance test for method (if --perf passed)\n```\n\n### Check sizes of methods\n\n```\nnpm run size \u003c...methods\u003e\nyarn size \u003c...methods\u003e\n\nParams\nmethods           List of method names (separated by space) you want to check.\n                  If no methods it will check size of all methods\n```\n\n### Check time of methods\n\n```\nnpm run time \u003c...methods\u003e\nyarn time \u003c...methods\u003e\n\n\nParams\nmethods           List of method names (separated by space) you want to check.\n                  If no methods it will check time of all possible methods (which have *.performance.js file)\n                  If type is set as no_perf (by default), it will throw an error: max.performance.js must have data to return\n```\n\n### Check ramda/nanoutils diff\n\n```\nnpm run method:check \u003ctype\u003e\nyarn method:check \u003ctype\u003e\n\nParams\ntype           What to display?\n               - both: display methods that are both in ramda and nanoutils\n               - nano: display nanoutils methods that ramda doesn't have\n               - ramda: display ramda methods that nanoutils doesn't have\n```\n\nWe use [size-limit](https://github.com/ai/size-limit) to check the size of methods.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnanoutils%2Fnanoutils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnanoutils%2Fnanoutils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnanoutils%2Fnanoutils/lists"}