{"id":20522004,"url":"https://github.com/imingyu/squirrel","last_synced_at":"2026-04-24T03:35:10.490Z","repository":{"id":44208822,"uuid":"278016679","full_name":"imingyu/squirrel","owner":"imingyu","description":"小松鼠——适用于JavaScript平台的数据上报工具","archived":false,"fork":false,"pushed_at":"2022-12-30T20:48:01.000Z","size":97,"stargazers_count":0,"open_issues_count":5,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-11T04:45:39.844Z","etag":null,"topics":["data-reports","report","reporting","timer-report"],"latest_commit_sha":null,"homepage":"","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/imingyu.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}},"created_at":"2020-07-08T07:09:20.000Z","updated_at":"2020-07-23T06:07:11.000Z","dependencies_parsed_at":"2023-01-31T16:31:04.632Z","dependency_job_id":null,"html_url":"https://github.com/imingyu/squirrel","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/imingyu/squirrel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imingyu%2Fsquirrel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imingyu%2Fsquirrel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imingyu%2Fsquirrel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imingyu%2Fsquirrel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imingyu","download_url":"https://codeload.github.com/imingyu/squirrel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imingyu%2Fsquirrel/sbom","scorecard":{"id":485563,"data":{"date":"2025-08-11","repo":{"name":"github.com/imingyu/squirrel","commit":"2089c5d0d6c25eb2b5ec0f8a1a5633ffca2e4faf"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/8 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":"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":"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":"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":"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":"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"}},{"name":"Vulnerabilities","score":0,"reason":"13 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-2j2x-2gpw-g8fm","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-g6ww-v8xp-vmwg","Warn: Project is vulnerable to: GHSA-hxcc-f52p-wc94","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T17:40:17.348Z","repository_id":44208822,"created_at":"2025-08-19T17:40:17.348Z","updated_at":"2025-08-19T17:40:17.348Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32208473,"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":["data-reports","report","reporting","timer-report"],"created_at":"2024-11-15T22:33:36.867Z","updated_at":"2026-04-24T03:35:10.475Z","avatar_url":"https://github.com/imingyu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# squirrel\n\n[![Build Status](https://travis-ci.org/imingyu/squirrel.svg?branch=master)](https://travis-ci.org/imingyu/squirrel)\n![image](https://img.shields.io/npm/l/squirrel-report.svg)\n[![image](https://img.shields.io/npm/v/squirrel-report.svg)](https://www.npmjs.com/package/squirrel-report)\n[![image](https://img.shields.io/npm/dt/squirrel-report.svg)](https://www.npmjs.com/package/squirrel-report)\n\n小松鼠——适用于 JavaScript 平台的数据上报工具，可指定多种上报策略\n\n## 使用场景\n- 上报埋点数据\n- 上报日志数据\n- 上报异常数据\n\n## 安装\n\n```bash\nnpm i squirrel-report -S\n```\n\n## 使用\n\n```javascript\nimport { Squirrel, DataLevel, SwallowStrategyMode } from \"squirrel-report\";\nconst reporter = new Squirrel({\n    adapter: (list) =\u003e {\n        // myAjax(list);\n    },\n    strategy: {\n        // 设置上传策略为：每满10条上报一次\n        mode: SwallowStrategyMode.intervalCount,\n        value: 10,\n    },\n});\n\n// 插入数据到队列池\nreporter.stuff(\"data1...\");\nreporter.stuff(\"data2...\", DataLevel.high);\n.\n.\n.\nreporter.stuff(\"data10...\"); // 触发上报\n\n// 也可以在任意时刻进行手动执行上报\nreporter.swallow();\n```\n\n## 上报策略\n\n```javascript\n// 上报策略可选值\nenum SwallowStrategyMode {\n    delayTime = \"delayTime\", // 延迟xx时间后，延迟时间内多次吞入会重新计时，单位ms\n    intervalTime = \"intervalTime\", // 每间隔xx时间，单位ms\n    intervalCount = \"intervalCount\", // 每间隔xx条数据\n    event = \"event\", // 当发生某事件时，需调用Squirrel实例的trigger方法进行事件触发\n    eventCount = \"eventCount\", // 当发生某事件xx次后，需调用Squirrel实例的trigger方法进行事件触发\n}\n```\n\n在使用构造函数`new Squirrel(options)`或者`squirrel.setOptions(options)`设置配置项时，可在`options`中传递`strategy`选项，用于指定上报策略；\n`strategy`的值可以是单纯的对象，如：\n```javascript\n{ mode: SwallowStrategyMode.intervalCount, value: 10}\n```\n\n也可以在`strategy`对象上按照优先级设置上报策略，如：\n\n```javascript\n{\n    [DataLevel.high]: {\n        mode: SwallowStrategyMode.intervalCount,\n        value: 10\n    }\n}\n```\n\n## API\n\n### class Squirrel\n\n-   `constructor(options:SquirrelOptions)`\n    -   构造函数，可传入`options`，使用`this.setOptions`进行配置项解析\n-   `setOptions(options:SquirrelOptions)`\n    -   解析并应用配置\n-   `stuff(data:any, level:DataLevel)`\n    -   将数据按照优先级插入到队列池中\n-   `swallow(data?:any, level?:DataLevel)`\n    -   强制执行上报操作，如果不传递任何参数或参数皆为空，则上报所有优先级的数据，如果传递的数据为空，但是存在优先级，则会上报该优先级下的所有数据\n-   `trigger(eventName)`\n\n    -   触发事件，Squirrel 类本身会触发如下事件：\n        -   `stuff`: 插入数据时触发\n        -   `swallow`: 上报数据时触发\n        -   `setOptions`: 设置配置项时触发\n        -   `storageError`: 在配置项中指定了`setStorage`，并且在执行数据持久化调用`setStorage`后失败时触发\n\n-   `destory()`\n    -   销毁实例，如果上报策略中指定了与实际相关的策略时，请务必执行此函数以销毁定时器\n\n### interface SquirrelOptions\n\n```typescript\n{\n    adapter: Function; // 发送数据时调用的函数，返回false或者reject状态的promise则认为此次数据发送失败，需要根据failAction配置执行后续操作\n    strategy: SwallowStrategy | LevelSwallowStrategy; // 上报策略\n    failAction: FailAction | FailActionCustom; // 如果发送数据失败了，该做什么？\n    getStorage?: Function; // 初始化Squirrel实例时从持久化介质中获取数据\n    setStorage?: Function; // 将数据持久化的函数\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimingyu%2Fsquirrel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimingyu%2Fsquirrel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimingyu%2Fsquirrel/lists"}