{"id":18059292,"url":"https://github.com/flo-bit/js-utils","last_synced_at":"2025-04-05T11:40:45.056Z","repository":{"id":173999925,"uuid":"589036280","full_name":"flo-bit/js-utils","owner":"flo-bit","description":"useful javascript methods","archived":false,"fork":false,"pushed_at":"2023-02-28T12:05:19.000Z","size":49,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T19:48:10.508Z","etag":null,"topics":["javascript","utilities"],"latest_commit_sha":null,"homepage":"https://flo-bit.github.io/js-utils/utils.js","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/flo-bit.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-14T21:09:32.000Z","updated_at":"2023-01-21T12:57:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"98826a08-4622-4f6e-bff5-da61782ff0ce","html_url":"https://github.com/flo-bit/js-utils","commit_stats":null,"previous_names":["flo-bit/js-utils"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flo-bit%2Fjs-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flo-bit%2Fjs-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flo-bit%2Fjs-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flo-bit%2Fjs-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flo-bit","download_url":"https://codeload.github.com/flo-bit/js-utils/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247332511,"owners_count":20921852,"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":["javascript","utilities"],"created_at":"2024-10-31T03:10:49.964Z","updated_at":"2025-04-05T11:40:45.036Z","avatar_url":"https://github.com/flo-bit.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# js-utils\n\nsome useful javascript methods and classes\n\n## Use\n\n```js\nimport Utils from \"https://flo-bit.github.io/js-utils/utils.js\";\nimport Vector from \"https://flo-bit.github.io/js-utils/vector.js\";\n```\n\n## Methods\n\n### Utils\n\n#### Utils.firstDefined\n\nreturn the first defined value\n\n```js\nUtils.firstDefined(undefined, 2, 3); // 2\nUtils.firstDefined(undefined, undefined, 3); // 3\nUtils.firstDefined(undefined, undefined, undefined); // undefined\n```\n\n#### Utils.merge\n\nmerge multiple objects with priority to earlier objects (works recursively and also deep clones)\n\n```js\nUtils.merge({ a: 1 }, { b: 2 }); // { a: 1, b: 2 }\nUtils.merge({ a: 1 }, { a: 2 }); // { a: 1 }\nUtils.merge({ a: { b: 3 } }, { a: { b: 1, c: 2 } }); // { a: {b: 3, c:2} }\n```\n\n#### Utils.deepClone\n\ndeep clone an object\n\n```js\nconst obj = { a: { b: 1 } };\nconst obj2 = Utils.deepClone(obj);\nobj2.a.b = 2;\nconsole.log(obj.a.b); // 1\n```\n\n#### Utils.resolve\n\nresolve all functions in an object\n\n```js\nconst obj = { a: () =\u003e 1 };\nUtils.resolve(obj); // { a: 1 }\n\nconst obj2 = { a: (n) =\u003e n + 1, b: (n) =\u003e n * 2 };\nUtils.resolve(obj2, 2); // { a: 3, b: 4 }\n```\n\n#### Utils.combine\n\n```js\nUtils.combine(a, b, (key = \"preset\"));\n```\n\nif a is not an object turn it into an object with `a[key] = a` return merge of a and `b[a[key]]`\n\n```js\nUtils.combine(\"a\", { a: { b: 3 } }); // { preset: \"a\", b: 3 }\nUtils.combine({ preset: \"a\", b: 3, c: 5 }, { a: { b: 10, c: 5 } }); // { preset: \"a\", b: 3, c: 5 }\n```\n\n#### Utils.loadScript\n\n#### Utils.number\n\n### Vector\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflo-bit%2Fjs-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflo-bit%2Fjs-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflo-bit%2Fjs-utils/lists"}