{"id":20671114,"url":"https://github.com/allnulled/pivotpath","last_synced_at":"2026-04-24T04:33:00.477Z","repository":{"id":57324977,"uuid":"134253607","full_name":"allnulled/pivotpath","owner":"allnulled","description":"Node.js library to pivot paths easily.","archived":false,"fork":false,"pushed_at":"2019-04-27T18:31:30.000Z","size":101,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-25T17:09:39.636Z","etag":null,"topics":[],"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/allnulled.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":"2018-05-21T10:22:36.000Z","updated_at":"2019-04-27T18:31:31.000Z","dependencies_parsed_at":"2022-09-06T09:20:25.880Z","dependency_job_id":null,"html_url":"https://github.com/allnulled/pivotpath","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/allnulled/pivotpath","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fpivotpath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fpivotpath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fpivotpath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fpivotpath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allnulled","download_url":"https://codeload.github.com/allnulled/pivotpath/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fpivotpath/sbom","scorecard":{"id":185833,"data":{"date":"2025-08-11","repo":{"name":"github.com/allnulled/pivotpath","commit":"45ec842f4c899702806dd3b8f38b2627d2c3dc00"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-16T19:47:06.342Z","repository_id":57324977,"created_at":"2025-08-16T19:47:06.342Z","updated_at":"2025-08-16T19:47:06.342Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32209893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T03:15:14.334Z","status":"ssl_error","status_checked_at":"2026-04-24T03:15:11.608Z","response_time":64,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-11-16T20:25:07.548Z","updated_at":"2026-04-24T04:33:00.462Z","avatar_url":"https://github.com/allnulled.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":" \n\n\n# pivotpath\n\n![](https://img.shields.io/badge/pivotpath-v1.1.3-green.svg) ![](https://img.shields.io/badge/tests-passing-green.svg) ![](https://img.shields.io/badge/coverage-100%25-green.svg) ![](https://img.shields.io/badge/stable-100%25-green.svg)\n\nNode.js module to easily create composed paths. It can:\n\n · Generate new paths (as strings).\n\n · Import modules from new paths (as `require(~)` would normally do).\n\n · Call to pure functional modules from new paths (as `require(~)(~)` would normally do).\n\n · Generate functions that call to pure functional modules from new paths. This is useful for \nExpressJS middlewares or controllers, for example, as they can be imported directly by a string,\nwhile this module takes care of generating and passing the proper parameters. See the examples to\neasily catch the idea.\n\n## 1. Installation\n\n`~$ npm install --save pivotpath`\n\n\n\n\n \n\n\n## 2. Usage\n\nThis is a full demonstration of the module:\n\n```js\n////////\n//////\n////\n// Intro) Generate a new PivotPath instance\nconst myPivot = require(\"pivotpath\").generate(__dirname + \"/my/folder/with/subPaths\");\n\n////////\n//////\n////\n// a) Generate new paths:\n\nconst myControllerPath = myPivot.get(\"/controllers/myController.js\");\nconst myMiddlewarePath = myPivot.get(\"/middlewares/myMiddleware.js\");\n\n////////\n//////\n////\n// b) Import modules from new paths:\n\nconst myController = myPivot.require(\"/controllers/myController.js\");\nconst myMiddleware = myPivot.require(\"/middlewares/myMiddleware.js\");\n// alternatively, you could use: myPivot.requireNewly(...) [to clear cache everytime it is executed]\n\n////////\n//////\n////\n// c) Call to pure functional modules from new paths:\n\nconst myData = myPivot.call(\"/functions/myFunction.js\", {scope:true}, [\"Param-1\", \"Param-2\", \"Param-3\"]);\nconst myOtherData = myPivot.call(\"/functions/myOtherFunction.js\", global, [1,2,3]);\n// alternatively, you could use: myPivot.callNewly(...) [to clear cache everytime it is executed]\n\n////////\n//////\n////\n// d) Generate functions that call to pure functional modules from new paths:\n\nconst app = require(\"express\")(); // This would be a new ExpressJS application.\napp.get(\"/\", myPivot.function(\"/controllers/main.js\")); // Adds a new controller\napp.get(\"/contact\", myPivot.function(\"/controllers/contact.js\")); // Adds a new controller\napp.get(\"/about\", myPivot.function(\"/controllers/about.js\")); // Adds a new controller\n// alternatively, you could use: myPivot.functionNewly(...) [to clear cache everytime it is executed]\n\n////////\n//////\n////\n// e) Generate functions through factory function from new paths:\n\nconst specialFunction = myPivot.factory(\"/factories/sumAndMultiply.js\", 5, 10); // 5 + 10\nconst result = specialFunction(3, 2); // (5 + 10) * 3 * 2 = 15 * 3 * 2 = 45 * 2 = 90\n// alternatuvely, you could use: myPivot.factoryNewly(...) [to clear cache of the factory file everytime the generated function is executed]\n\n```\n\n## 3. API Reference\n\n\n\n\n\n\n \n\n\n----\n\n### `PivotPath`\n\n**From:** `require(\"pivotpath\")`\n\n**Type:** `{Class}`\n\n**Description:** The API of the module starts is inside this object.\n\n\n\n \n\n\n----\n\n### `PivotPath.generate(basePath=\".\")`\n\n**Access:** `{Static}`\n\n**Type:** `{Class method}`\n\n**Parameter:** `{String} basePath`. Optional. Path from which all the others will start from. By default: `\".\"`.\n\n**Returns:** `{PivotPath}`. A `{PivotPath}` fresh instance is returned.\n\n**Description:** Instantiates a new `{PivotPath}` instance, using the provided path as basePath.\n\n\n\n \n\n\n----\n\n### `PivotPath#setBasePath(basePath)`\n\n**Type:** `{Function}`\n\n**Parameter:** `{String} basePath`. Required. Path from which all the others will start from.\n\n**Returns:** `{PivotPath}`. A `{PivotPath}` fresh instance is returned.\n\n**Description:** Instantiates a new `{PivotPath}` instance, using the provided path as basePath.\n\n\n\n\n \n\n\n----\n\n### `PivotPath#get(subPath)`\n\n**Type:** `{Function}`\n\n**Parameter:** `{String} subPath`. Required. The subPath choosen.\n\n**Returns:** `{String}`. The path generated from the basePath and the subPath.\n\n**Description:** Generates and returns a new path from the union of the basePath and the subPath provided.\n\n\n\n \n\n\n----\n\n### `PivotPath#require(subPath)`\n\n**Type:** `{Function}`\n\n**Parameter:** `{String} subPath`. Required. The subPath choosen.\n\n**Returns:** `{Any}`. The module that is found at the path generated from the basePath and the subPath.\n\n**Description:** Generates a new path from the union of the basePath and the subPath provided and imports the module that is found at that new path.\n\n\n\n \n\n\n----\n\n### `PivotPath#requireNewly(subPath)`\n\n**Type:** `{Function}`\n\n**Parameter:** `{String} subPath`. Required. The subPath choosen.\n\n**Returns:** `{Any}`. The module that is found at the path generated from the basePath and the subPath.\n\n**Description:** This method does the same as the `PivotPath#require(...)` method, but it clears the cache of the module before requiring it.\n\n\n\n \n\n\n----\n\n### `PivotPath#call(subPath)`\n\n**Type:** `{Function}`\n\n**Parameter:** `{String} subPath`. Required. The subPath choosen.\n\n**Parameter:** `{Any} scope`. Optional. The scope of the call. By default: `null`.\n\n**Parameter:** `{Array\u003cAny\u003e} params`. Optional. The arguments of the call, as `{Array}`. By default: `[]`.\n\n**Returns:** `{Any}`. The result of the call of the module that is found at the path generated from the basePath and the subPath, \nreceiving the parameters and applying the indicated scope.\n\n**Description:** Generates a new path from the union of the basePath and the subPath provided and imports the module that is found at that new path,\nand afterwards, it calls it, prosupposing that the module imported is always a plain function. It applies the scope and passes the parameters \nprovided automatically. Finally, it returns the result of that call.\n\n\n\n \n\n\n----\n\n### `PivotPath#callNewly(subPath)`\n\n**Type:** `{Function}`\n\n**Parameter:** `{String} subPath`. Required. The subPath choosen.\n\n**Parameter:** `{Any} scope`. Optional. The scope of the call. By default: `null`.\n\n**Parameter:** `{Array\u003cAny\u003e} params`. Optional. The arguments of the call, as `{Array}`. By default: `[]`.\n\n**Returns:** `{Any}`. The result of the call of the module that is found at the path generated from the basePath and the subPath, \nreceiving the parameters and applying the indicated scope.\n\n**Description:** This method does the same as the `PivotPath#call(...)` method, but it clears the cache of the module before requiring it.\n\n\n\n \n\n\n----\n\n### `PivotPath#function(subPath)`\n\n**Type:** `{Function}`\n\n**Parameter:** `{String} subPath`. Required. The subPath choosen.\n\n**Parameter:** `{Any} scope`. Optional. The scope of the call. By default: `null`.\n\n**Parameter:** `{Array\u003cAny\u003e} params`. Optional. The arguments of the call that will be automatically prepended, as `{Array}`. By default: `[]`.\n\n**Returns:** `{Function}`. A function that imports the specified path, and calls to it using the scope provided and prepending the parameters provided.\n\n**Description:** Generates a new path from the union of the basePath and the subPath provided. Then, it returns a function that will import the specified path,\napply the provided scope and prepend the specified parameters, meanwhile it can receive any other parameters. Note that, if you understood well how this \nmethod works, you understand that this method will only work well when the module that is being required is a function itself.\n\n\n\n \n\n\n----\n\n### `PivotPath#functionNewly(subPath)`\n\n**Type:** `{Function}`\n\n**Parameter:** `{String} subPath`. Required. The subPath choosen.\n\n**Parameter:** `{Any} scope`. Optional. The scope of the call. By default: `null`.\n\n**Parameter:** `{Array\u003cAny\u003e} params`. Optional. The arguments of the call that will be automatically prepended, as `{Array}`. By default: `[]`.\n\n**Returns:** `{Function}`. A function that imports the specified path, and calls to it using the scope provided and prepending the parameters provided.\n\n**Description:** This method does the same as the `PivotPath#function(...)` method, but it clears the cache of the module before requiring it.\n\n\n\n \n\n\n----\n\n### `PivotPath#factory(subPath, ...params)`\n\n**Type:** `{Function}`\n\n**Parameter:** `{String} subPath`. Required. The subPath choosen. This path must point to a file that returns as module a factory function of a [possibly externally contextualized] function.\nWhat this file must have as code is something like this:\n```js\nmodule.exports = function(...factoryArguments) {\n return function(...functionArguments) {\n   // Content of the returned function.\n };\n};\n```\nSee the description to see what this method is exactly supposed to do.\n\n**Parameters:** `{...Any} params`. Optional. The arguments for the factory.\n\n**Returns:** `{Function}`. A function that is generated through a **factory** function, but keeping the context and arguments of the generated function separated from the arguments of the factory function.\n\n**Description:** This method:\n - Generates a function that has independent arguments and context.\n - Generates a function through another factory function, which also has its own arguments (the context is, though, undefined).\n - Generates a function through an external module (which has this factory function, which, in turn, returns the final function).\nIt may sound a bit confusing, but it is simple:\n - A function that, with some parameters, generates a function that, with some arguments and context, does something.\n\n\n\n\n \n\n\n----\n\n### `PivotPath#factoryNewly(subPath, ...params)`\n\n**Type:** `{Function}`\n\n**Parameter:** `{String} subPath`. Required. The subPath choosen. This path must point to a file that returns as module a factory function of a [possibly externally contextualized] function.\nWhat this file must have as code is something like this:\n```js\nmodule.exports = function(...factoryArguments) {\n return function(...functionArguments) {\n   // Content of the returned function.\n };\n};\n```\nSee the description to see what this method is exactly supposed to do.\n\n**Parameters:** `{...Any} params`. Optional. The arguments for the factory.\n\n**Returns:** `{Function}`. A function that is generated through a **factory** function, but keeping the context and arguments of the generated function independent of the factory arguments.\n\n**Description:** This method does the same thing as `factory` method, but clearing the cache before.\n\n\n\n \n\n\n## 4. Commands (npm run *)\n\nTo build the project (clean and install dependencies):\n\n~$ `npm run build`\n\nTo pass the tests:\n\n~$ `npm run test`\n\nTo pass the tests and generate the coverage reports:\n\n~$ `npm run coverage`\n\nTo clean regenerable directories:\n\n~$ `npm run clean`\n\nTo generate the documentation from Javadoc comments:\n\n~$ `npm run docs`\n\n\n\n## 5. Conclusion\n\nVery simple module, but can be useful for shortening some repetitive codes, and improve easily\nthe readability of your code.\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallnulled%2Fpivotpath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallnulled%2Fpivotpath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallnulled%2Fpivotpath/lists"}