{"id":23293395,"url":"https://github.com/garethslinn/helprjs","last_synced_at":"2025-08-22T00:33:01.967Z","repository":{"id":46207800,"uuid":"332876735","full_name":"garethslinn/helprjs","owner":"garethslinn","description":"This is an open-source project which recognizes neurodiversity through the various methods of documentation.  This project has a live demo for all its methods and new methods must have a link to a live demo.  To contribute please folk and raise a pull request.  Thank you. ","archived":false,"fork":false,"pushed_at":"2024-06-14T19:12:07.000Z","size":337,"stargazers_count":19,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-08T04:09:35.487Z","etag":null,"topics":["array","javascript","json","library","object","opensource","typescript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/garethslinn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-25T20:38:09.000Z","updated_at":"2024-06-14T19:12:10.000Z","dependencies_parsed_at":"2023-12-25T09:03:15.424Z","dependency_job_id":"77b4b4a8-e5e7-4765-a4b0-b14729258129","html_url":"https://github.com/garethslinn/helprjs","commit_stats":{"total_commits":172,"total_committers":3,"mean_commits":"57.333333333333336","dds":0.01744186046511631,"last_synced_commit":"1f0ae0929528d229af067dca4cb1b51d1b3fb25b"},"previous_names":["garethslinn/useful_functions"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garethslinn%2Fhelprjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garethslinn%2Fhelprjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garethslinn%2Fhelprjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garethslinn%2Fhelprjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/garethslinn","download_url":"https://codeload.github.com/garethslinn/helprjs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230542252,"owners_count":18242333,"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":["array","javascript","json","library","object","opensource","typescript"],"created_at":"2024-12-20T06:15:42.367Z","updated_at":"2024-12-20T06:15:43.161Z","avatar_url":"https://github.com/garethslinn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# helprjs\n\nA toolkit to help solve challenging tasks with object and arrays.\nHelprjs is fully documented with live Demos and its really simple to use!\n\n\n## Q\u0026A: \nWhilst helprjs is fully tested should you ecounter issues please report them.\n\n## Most of the examples here make use of this people object.\n\n```\nconst people = [\n    { id: 1, firstName: 'John', secondName: 'Smith', age: '61', status: 1 },\n    { id: 2, firstName: 'John', secondName: 'West', age: '55', status: true },\n    { id: 3, firstName: 'Brenda', secondName: 'Holt', age: '60', status: false },\n    { id: 4, firstName: 'Sally', secondName: 'Brampton', age: '33', status: undefined },\n    { id: 5, firstName: 'June', secondName: 'Chester', age: '47', status: NaN },\n    { id: 6, firstName: 'Jack', secondName: 'Carter', age: '24', status: null },\n    { id: 7, firstName: 'Jack', secondName: 'Foster', age: '58', status: 0 },\n    { id: 7, firstName: 'Jack', secondName: 'Foster', age: '58', status: 0 },\n    { id: 7, firstName: 'Jack', secondName: 'Foster', age: '58', status: 0 },\n];\n```\n\n## Methods\n\nMethods can be grouped into the following categories: \n\nGeneral : object array manipulation \n\nArray: array only\n\nBoolean : returns true or false\n\nHelpers : deals with values\n\nNumerical : uses numerical data\n\nVailidation : returns only objects that meet the valid criteria\n\n## Latest\n\n####  maskSensitiveData\n```\nMasks sensitive data\nUseage:\n\nconst people = [\n    { id: 1, firstName: 'John', secondName: 'Smith', age: '61', status: 1 },\n    { id: 2, firstName: 'John', secondName: 'West', age: '55', status: true },\n];\n\nconst masked = maskSensitiveData(people, ['firstName', 'secondName']);\n\nOutput: \n[\n    { id: 1, firstName: '****', secondName: '*****', age: '61', status: 1 },\n    { id: 2, firstName: '****', secondName: '****', age: '55', status: true },\n]\n```\n\n####  findAllDuplicates\n```\nreturns an array of duplicate objects\n\nUseage:\n\nconst people: Person[] = [\n    { id: 1, firstName: \"John\", secondName: \"Smith\", age: \"61\", status: 1 },\n    { id: 2, firstName: \"John\", secondName: \"West\", age: \"55\", status: true },\n    { id: 3, firstName: \"Brenda\", secondName: \"Holt\", age: \"60\", status: false },\n    { id: 4, firstName: \"Sally\", secondName: \"Brampton\", age: \"33\", status: undefined },\n    { id: 5, firstName: \"June\", secondName: \"Chester\", age: \"47\", status: NaN },\n    { id: 6, firstName: \"Jack\", secondName: \"Carter\", age: \"24\", status: null },\n    { id: 7, firstName: \"Jack\", secondName: \"Foster\", age: \"58\", status: 0 },\n    { id: 7, firstName: \"Jack\", secondName: \"Foster\", age: \"58\", status: 0 },\n    { id: 7, firstName: \"Jack\", secondName: \"Foster\", age: \"58\", status: 0 },\n];\n\nconst duplicates = findAllDuplicates(people);\nconsole.log(duplicates);\n\n[\n  { id: 7, firstName: 'Jack', secondName: 'Foster', age: '58', status: 0 },\n  { id: 7, firstName: 'Jack', secondName: 'Foster', age: '58', status: 0 },\n  { id: 7, firstName: 'Jack', secondName: 'Foster', age: '58', status: 0 }\n]\n```\n\n\n## General\n\n####  mergeArraysRemoveDuplicates - [Demo](https://codesandbox.io/p/devbox/merge-arrays-remove-duplicates-lkfzxc?file=%2Fsrc%2FApp.tsx%3A15%2C1)\n```\nmerges two arrays and removes all duplicates\nUseage:\n\nconst array1 = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];\nconst array2 = [{ id: 2, name: 'Bob' }, { id: 3, name: 'Charlie' }];\n\nconst mergedArray = mergeArraysRemoveDuplicates(array1, array2);\n```\n\n\n####  deGroup - [Demo](https://codesandbox.io/s/groupbyid-lv5mp?file=/src/App.js)\n```\nreverses a grouped object.\ndeGroup(people, groupObject)\nreturns 9 objects\n```\n\n####  objectToArray - [Demo](https://codesandbox.io/s/objecttoarray-hmbbsg?file=/src/App.js)\n```\npass in an object\nUseage: objectToArray({firstName: 'Mike', lastName: 'Jones', age: 34, registered: true})\nReturns ['Mike', 'Jones', 34, true]\n```\n####  arrayToObject - [Demo](https://codesandbox.io/s/arraytoobject-r3lwcz?file=/src/App.js)\n```\npass in an array of values\nUseage: arrayToObject([\"Mike\",\"Jones\",34,true])\nReturns {0: 'Mike', 1: 'Jones', 2: 34, 3: true}\n\npass in an array of values and custom keys\nUseage: arrayToObject([\"Mike\",\"Jones\",34,true], [\"firstName\", \"lastName\",\"age\",\"registered\"])\nReturns {firstName: 'Mike', lastName: 'Jones', age: 34, registered: true}\n```\n\n#### addNewProperty - [Demo](https://codesandbox.io/s/addnewproperty-unbg66?file=/src/App.js)\n```\naddNewProperty(people, 'registered', true)\nadds new key/value to all objects.\n```\n\n#### countKeys - [Demo](https://codesandbox.io/s/countkeys-oojbt)\n```\ncountKeys({a:1, b:2, c:3});\n// 3\n```\n\n#### CSVtoArray - [Demo](https://codesandbox.io/s/csvto-skj8q?file=/src/App.js)\n```\nCSVtoArray(csvfile');\n// [ {...} {...} ]\n```\n\n#### getEven - [Demo](https://codesandbox.io/s/geteven-fdv6c)\n```\ngetEven(people,'age');\nreturns objects containing only even values\n```\n\n#### getObject - [Demo](https://codesandbox.io/s/suspicious-tu-859vt)\n```\ngetObject(people,2);\nreturns an object from an array from array key\n```\n\n#### getOdd - [Demo](https://codesandbox.io/s/getodd-lsj78)\n```\ngetOdd(people,'age');\nreturns objects containing only odd values\n```\n\n#### getValues - [Demo](https://codesandbox.io/s/getvalues-34vg2?file=/src/App.js)\n```\ngetValues(people, 'firstName');\n// [\"John\", \"John\", \"Brenda\", \"Sally\", \"June\", \"Jack\", \"Jack\"]\n```\n\n#### groupByKey - [Demo](https://codesandbox.io/s/groupbyid-lv5mp?file=/src/App.js)\n```\ngroupByKey(people, 'firstName')\n// {John: Array(2), Brenda: Array(1), Sally: Array(1), June: Array(1), Jack: Array(2)}\n```\n\n#### mergeArrays - [Demo](https://codesandbox.io/s/mergearrays-p130j?file=/src/App.js)\n\n```\n\nmergeArrays(arr1,arr2,key); \nreturns a single merged array\n\n```\n\n#### randomOrder - [Demo](https://codesandbox.io/s/randomorder-9mc74)\n```\nrandomOrder(people);\nreturns randomly ordered array\n```\n\n#### refine - [Demo](https://codesandbox.io/s/refine-fdv6c?file=/src/App.js)\n```\nconst result = refine(people, \"firstName\", \"Jack\");\n// return only objects that match criteria\n```\n\n#### removeDuplicates  - [Demo](https://codesandbox.io/s/removeduplicates-do4oe?file=/src/App.js)\n```\nremoveDuplicates(people, 'firstName');\nremoves all objects containing duplicates values\n```\n\n#### removeFalsy - [Demo](https://codesandbox.io/s/removefalsy-y05sr)\n```\nremoveFalsy(people, 'status');\nremoves all objects containing falsy values\n```\n\n#### removeValue - [Demo](https://codesandbox.io/s/removevalue-2uynr)\n```\nremoveValue(people,'firstName', 'John');\nremove all objects that have this value\nNote: 1 and '1' will give a different result, be sure to include quotation marks if targetting a string\n```\n\n#### setAllValues - [Demo](https://codesandbox.io/s/setallvalues-b61xe)\n```\nsetAllValues(people, 'age', '25');\n(sets all values to 25)\n```\n\n#### sortByKey - [Demo](https://codesandbox.io/s/ortbykey-3js9v)\n```\nsortByKey(people, 'age', 'desc');\nreturns object in value order\nNote, 3rd paramenter is optional.  desc = decending order.\n```\n\n#### toArray - [Demo](https://codesandbox.io/s/toarray-n67wv?file=/src/App.js)\n```\ntoArray(people, 'age');\n// [\"61\",\"55\",\"60\",\"33\",\"47\",\"24\",\"58\"]\n```\n\n#### toLower - [Demo](https://codesandbox.io/s/tolower-8wu14?file=/src/App.js)\n```\ntoLower(people, 'firstName');\nreturns object with values as lowercase\n```\n\n#### toUpper - [Demo](https://codesandbox.io/s/toupper-35cel?file=/src/App.js)\n```\ntoUpper(people, 'firstName');\nreturns object with values as uppercase\n```\n\n#### toString - [Demo](https://codesandbox.io/s/tostring-q4jhu)\n```\ntoString(people, 'id');\nreturns object with values as a string\n```\n\n#### toTruncate - [Demo](https://codesandbox.io/s/totruncate-34fcb?file=/src/App.js)\n```\ntoTruncate(people, 'firstName', 3);\nreturns object with values truncated to numerical value\n```\n\n#### toNumber - [Demo](https://codesandbox.io/s/tonumber-i0kr7?file=/src/App.js)\n```\ntoNumber(people, 'age');\nreturns object with values as numbers\n```\n\n#### toTrim - [Demo](https://codesandbox.io/s/totrim-hdtfu?file=/src/App.js)\n```\ntoTrim(people, 'firstName');\nreturns object values with whitespace removed\n```\n\n\n## Array\n\n####  isEmptyArray\n```\nisEmptyArray([1,2]);\nfalse\n```\n\n####  getAverage \n```\ngetAverage([1, 2, 3, 4, 4, 4]));\n3\n```\n\n####  concatArray - [Demo](https://codesandbox.io/s/concatarray-69w8ly?file=/src/App.js)\n```\npass in an array of arrays\nUseage: concatArray([ [1,2],[\"three\", \"four\"],[5],[6] ])\nReturns [1,2,\"three\",\"four\",5,6]\n```\n#### populateArray - [Demo](https://codesandbox.io/s/populatearray-suvdi?file=/src/App.js)\n```\npopulateArray(0,20,4)\n// [4,8,12,16,20]\n```\n\n#### uniqueArray - [Demo](https://codesandbox.io/s/uniquearray-2uoe1?file=/src/App.js)\n```\nuniqueArray([\"one\",1,1,2,3,\"two\",\"three\",\"four\",\"one\",\"two\"])\n// [\"one\", 1, 2, 3, \"two\", \"three\", \"four\"]\n```\n\n#### emptyArray - [Demo](https://codesandbox.io/s/emptyarray-4hgb1?file=/src/App.js)\n```\nemptyArray([\"one\",\"two\",\"three\",\"four\"])\n// []\n```\n\n#### reverseArray - [Demo](https://codesandbox.io/s/reversearray-6hvt4?file=/src/App.js)\n```\nreverseArray([0,1,2,3,4,5,6])\n// [6,5,4,3,2,1,0]\n```\n\n#### shuffleArray - [Demo](https://codesandbox.io/s/shufflearray-qq4yy?file=/src/App.js)\n```\nshuffleArray([0,1,2,3,4,5,6])\n// [4,0,1,6,5,3,2]\n```\n\n\n## Boolean\n\n#### isAll - [Demo](https://codesandbox.io/s/isall-y3ch8?file=/src/App.js)\n```\npass in object array, key and function. \n\nconst isBelow = (currentValue) =\u003e currentValue \u003c 99;\nconst result = isAll(people, 'age', isBelow)\nconsole.log('result', result)\n// true\n```\n\n#### isPresent - [Demo](https://codesandbox.io/s/ispresent-y3ch8?file=/src/App.js)\n```\npass in object array, key and function. \n\nconst age = 48;\nconst isBelow = (currentValue) =\u003e currentValue \u003c age;\nconst result = isPresent(people, \"age\", isBelow);\nconsole.log('result', result)\n// true\n```\n\n#### isArray - [Demo](https://codesandbox.io/s/isarray-8k28g?file=/src/App.js:0-222)\n```\nisArray([1,2,3]);\n// true\n```\n\n#### isBigint - [Demo](https://codesandbox.io/s/isbigint-s5f4d?file=/src/App.js)\n```\nisBigint(9007199254740991n);\n// true\n```\n\n#### isBoolean - [Demo](https://codesandbox.io/s/isboolean-53rq4?file=/src/App.js)\n```\nisBoolean(true);\n// true\n```\n\n#### isNaN - [Demo](https://codesandbox.io/s/isnan-e6xfc?file=/src/App.js)\n```\nisNaN(NaN);\n// true\n```\n\n#### isNull - [Demo](https://codesandbox.io/s/isnull-7l5ds?file=/src/App.js)\n```\nisNull(null);\n// true\n```\n\n#### isNumber - [Demo](https://codesandbox.io/s/isnumber-nz40w?file=/src/App.js)\n```\nisNumber(1);\n// true\n```\n\n#### isObject - [Demo](https://codesandbox.io/s/isnumber-nz40w?file=/src/App.js)\n```\nisObject({x:1, y:2});\n// true\n```\n\n#### isString - [Demo](https://codesandbox.io/s/isstring-0prvt?file=/src/App.js)\n```\nisString('abc'});\n// true\n```\n\n#### isSymbol - [Demo](https://codesandbox.io/s/issymbol-z8cti?file=/src/App.js)\n```\nisSymbol(Symbol());\n// true\n```\n\n#### isUndefined - [Demo](https://codesandbox.io/s/isundefined-88xpm?file=/src/App.js)\n```\nisUndefined(undefined);\n// true\n```\n\n## Helpers\n\n#### percentage - [Demo](https://codesandbox.io/s/percentage-rh65d?file=/src/App.js)\n```\npercentage(partial, total)\n\n// percentage(50, 200)\n// 25\n// calculate percentage of partial against total number\n```\n\n#### typeOf - [Demo](https://codesandbox.io/s/typeof-uuuc9?file=/src/App.js)\n```\ntypeOf(value);\n\n// typeOf(1); returns \"number\"\n// typeOf([1,2,3]); returns \"array\"\n// typeOf({x: 1}); returns \"object\"\n```\n\n#### randomId - [Demo](https://codesandbox.io/s/randomid-jgznb?file=/src/App.js)\n```\nrandomId();\n\n// Random ID generator\n// zxrm95d6ug\n```\n\n## String\n\n```\ncapitalise('hello world')\nReturns 'Hello world'\n```\n\n\n\n## Numerical \n\n#### getMaximum - [Demo](https://codesandbox.io/s/getmaximum-swhbw)\n```\ngetMaximum(people,'age');\n// 61\n```\n\n#### getMinimum - [Demo](https://codesandbox.io/s/getminimum-2fn0k)\n```\ngetMinimum(people,'age');\n// 24\n```\n\n#### getTotal - [Demo](https://codesandbox.io/s/gettotal-tlu96)\n```\ngetTotal(people, 'age');\nreturns sum total\n```\n\n## Validation\n\n#### getValidEmail \n```\ngetValidEmail( [\n    { id: 1, email: 'badEmailDotgmail.com'  },\n    { id: 2, email: 'test@validEmail.com'  },\n    { id: 3, email: 'test@badEmail' }\n],'email')\nreturns only objects containing valid email addresses \n```\n\n#### getValidString\n```\ngetValidString(people, 'firstName', 5, 99)\n//Note: (array, key, minimumLength, maximumLength)\nreturns only objects containing text within min and max length\n```\n\n## Combination - [Demo](https://codesandbox.io/s/combination-2use4)\n\n```\nIn this example five methods have been used to generate a desired output.  \nIt is overengineered and an unlikely requirement however it demonstrates \nmore possibilities when using helprjs.  \n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarethslinn%2Fhelprjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgarethslinn%2Fhelprjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarethslinn%2Fhelprjs/lists"}