{"id":16726282,"url":"https://github.com/cmd-johnson/node-power-info","last_synced_at":"2025-09-07T03:37:36.711Z","repository":{"id":36451961,"uuid":"40757026","full_name":"cmd-johnson/node-power-info","owner":"cmd-johnson","description":"Cross-platform node library for accessing battery power information","archived":false,"fork":false,"pushed_at":"2018-08-05T23:08:45.000Z","size":42,"stargazers_count":3,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-30T07:26:11.311Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/node-power-info","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/cmd-johnson.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-15T12:03:30.000Z","updated_at":"2020-10-09T08:12:14.000Z","dependencies_parsed_at":"2022-07-20T23:54:17.823Z","dependency_job_id":null,"html_url":"https://github.com/cmd-johnson/node-power-info","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/cmd-johnson/node-power-info","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmd-johnson%2Fnode-power-info","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmd-johnson%2Fnode-power-info/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmd-johnson%2Fnode-power-info/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmd-johnson%2Fnode-power-info/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cmd-johnson","download_url":"https://codeload.github.com/cmd-johnson/node-power-info/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmd-johnson%2Fnode-power-info/sbom","scorecard":{"id":294045,"data":{"date":"2025-08-11","repo":{"name":"github.com/cmd-johnson/node-power-info","commit":"5c74b4e25f4f7fcc122a1bd02a7fc31cf636b732"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"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":"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":"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":"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/29 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":"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":"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":"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":"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":"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"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"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T19:00:46.431Z","repository_id":36451961,"created_at":"2025-08-17T19:00:46.431Z","updated_at":"2025-08-17T19:00:46.431Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273993026,"owners_count":25203792,"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","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-10-12T22:52:43.218Z","updated_at":"2025-09-07T03:37:36.654Z","avatar_url":"https://github.com/cmd-johnson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-power-info\nCross-platform node library for accessing battery and power adapter information\n\n## Features\nReads power status in percent, along with information on the charge mode of all\ninstalled batteries (charging, discharging, full, unknown) as well as the\nestimated remaining time until the battery is fully (dis-)charged.\n\n## Cross-platform\nFor the time being, only supports linux and darwin platforms. Windows is planned\nbut it could take some time until I get to do that.\nIf you think you can provide an implementation for windows or any other platform,\nfeel free to make a pull request!\n\n## Known issues\nSince I'm not owning a mac, the darwin implementation is completely untested. The\ncurrent solution simply runs `pmset -g batt` to get basic information on the\nbatteries installed and runs the output through a regex to extract percentage\nand charge status data. That should work in theory, but if you have time to test\nit in a real environment (possibly including some edge cases, like output when\nat 100%), please, take that time and report your findings!\n\n## How it works\nTo get information on the available batteries, the module sports a list of\ninformation providers that are each supported on different systems. When\nrequiring the module, it first checks every provider for availability. The first\nfound supported provider will be used as default provider for accessing battery\ninformation.\n\nIn this way, the module doesn't depend on node's `require('os').type()` value,\nbut tries all available options for maximum compatibility.\n\n## Example\n```js\nconst powerInfo = require('node-power-info')\n\npowerInfo.getDefault()\n  .then(provider =\u003e provider.getBatteries())\n  .then(batteries =\u003e batteries.forEach(battery =\u003e {\n    console.dir(battery)\n    console.log(`${battery.id} is at ${battery.powerLevel}% and ${battery.chargeStatus}.`)\n    if (battery.isTimeAvailable) {\n      const remainingMinutes = ('0' + battery.remainingTimeMinutes).slice(-2)\n      console.log(`${battery.remainingTimeHours}:${remainingMinutes} remaining`)\n    }\n  }))\n```\n\n## API\n### `powerInfo`\n#### `powerInfo.getDefault(): Promise\u003cProvider\u003e`\nResolves to the default provider as soon as all providers were checked for\navailability.\n\n#### `powerInfo.getSupportedProviders(): Promise\u003cProvider[]\u003e`\nResolves to a list of all providers that are supported on the current system.\n\n#### `powerInfo.providers: Provider[]`\nA list of all providers known to the module, disregarding if they are\nsupported or not.\n\n### `Provider`\n#### `Provider.name: string`\nThe name of the provider.\n\n#### `Provider.getBatteries(): Promise\u003cBattery[]\u003e`\nFetches information on all available batteries.\n\n#### `Provider.checkIsSupported(): Promise\u003cboolean\u003e`\nResovles to true if the provider is available on the current system.\n\n### `Battery`\n#### `Battery.id: string`\nThe id of the battery as provided by the OS.\n\n#### `Battery.powerLevel: number`\nThe power level of the battery in percent.\n\n#### `Battery.chargeStatus: string`\nThe battery's status. Either `'charging'`, `'discharging'`, `'full'` or\n`'unknown'`.\n\n#### `Battery.isTimeAvailable: boolean`\nTrue if a remaining time was set.\n\n#### `Battery.remainingTimeHours: number`\nThe remaining (dis-)charge time in whole hours, rounded down.\nIs null if `isTimeAvailable` is  `false`.\n\n#### `Battery.remainingTimeMinutes: number`\nThe remaining (dis-)charge time in minutes after subtracting the remaining\nhours, rounded down.\nIs null if `isTimeAvailable` is  `false`.\n\n## Licence\nMIT Licence (see LICENSE file)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmd-johnson%2Fnode-power-info","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcmd-johnson%2Fnode-power-info","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmd-johnson%2Fnode-power-info/lists"}