{"id":16329976,"url":"https://github.com/luin/node_ranaly","last_synced_at":"2026-03-06T07:03:00.862Z","repository":{"id":6890918,"uuid":"8140504","full_name":"luin/node_ranaly","owner":"luin","description":"Ranaly client library","archived":false,"fork":false,"pushed_at":"2014-06-04T12:58:18.000Z","size":131,"stargazers_count":20,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-03T13:57:27.037Z","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/luin.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":"2013-02-11T15:31:07.000Z","updated_at":"2025-02-06T16:02:01.000Z","dependencies_parsed_at":"2022-09-21T05:04:58.481Z","dependency_job_id":null,"html_url":"https://github.com/luin/node_ranaly","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/luin/node_ranaly","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luin%2Fnode_ranaly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luin%2Fnode_ranaly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luin%2Fnode_ranaly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luin%2Fnode_ranaly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luin","download_url":"https://codeload.github.com/luin/node_ranaly/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luin%2Fnode_ranaly/sbom","scorecard":{"id":603402,"data":{"date":"2025-08-11","repo":{"name":"github.com/luin/node_ranaly","commit":"bcedcfd0da64938e3ece753ef22d9c0391dab935"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"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":"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":"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":"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":"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":"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":"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":"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":"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":"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":"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-21T00:59:17.305Z","repository_id":6890918,"created_at":"2025-08-21T00:59:17.305Z","updated_at":"2025-08-21T00:59:17.305Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30164900,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T04:43:31.446Z","status":"ssl_error","status_checked_at":"2026-03-06T04:40:30.133Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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-10-10T23:17:58.778Z","updated_at":"2026-03-06T07:03:00.804Z","avatar_url":"https://github.com/luin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ranaly - a node.js ranaly client\n[![Build Status](https://travis-ci.org/luin/node_ranaly.png?branch=master)](https://travis-ci.org/luin/node_ranaly)\n\nRanaly可以非常简单地统计项目中的各种数据，本项目是ranaly的node.js客户端。想要了解更多关于ranaly的介绍请访问[ranaly项目主页](https://github.com/luin/ranaly)。\n\n## 安装\n\n\tnpm install node_ranaly\n\n## 使用方法\n首先加载ranaly库：\n\t\n\tvar ranaly = require('node_ranaly');\n\n而后创建ranaly连接：\n\n\tvar client = ranaly.createClient(port, host, keyPrefix);\n\n其中`post`和`host`是Redis数据库的端口号和主机地址，`keyPrefix`用来指定ranaly向Redis加入的键的前缀以防止命名冲突，默认值是`RANALY:`。\n\n如果程序中已经使用[node_redis](https://github.com/mranney/node_redis)库建立了到Redis的连接，也可以将该实例传入createClient函数：\n\n\tvar redis = require('redis').createClient();\n\tvar client = ranaly.createClient(redis, keyPrefix);\n\nRanaly支持3种数据类型，分别是Amount、Realtime和DataList。\n## Amount\n创建一个Amount实例：\n\n\tvar users = new client.Amount('Users');\n\n### incr\n`incr`方法用来增加实例的值，如每当有新用户注册时可以通过如下方法增加用户数量：\n\t\n\tusers.incr(function (err, total) {\n\t\tconsole.log('用户总数为：' + total + '个');\n\t});\n\n`incr`函数的定义是：\n\n\tincr([increment, [when, [callback]])\n\n其中`increment`指增加的数量，默认为1。`when`指增长发生的时间，`Date`类型，默认为`new Date()`，即当前时间。`callback`的第二个参数返回增长后的总数。\n\n### get\n`get`方法用来获取实例在若干个时间的数量，如：\n\n\tusers.get(['20130218', '20130219'], function (err, result) {\n\t\tconsole.log(result);\n\t});\n\n第一个参数是时间的数组，时间的表示方法为`YYYYMMDD`或`YYYYMMDDHH`。如想获取今天和当前小时的注册用户数量：\n\n\tvar now = moment(); // 需要使用moment库\n\tusers.get([now.format('YYYYMMDD'), now.format('YYYYMMDDHH')], function (err, results) {\n\t\tconsole.log('今天新注册的用户数量：' + results[0]);\n\t\tconsole.log('当前小时新注册的用户数量：' + results[1]);\n\t});\n\n### sum\n`sum`方法用来获取实例在若干个时间内总共的数量，使用方法和`get`一样，不再赘述。特例是当第一个参数为空时，`sum`会返回该Amount实例的总数。如：\n\n\tusers.sum([], function (err, result) {\n\t\tconsole.log('用户总数为：' + total + '个');\n\t});\n\t\n## Realtime\n创建一个Realtime实例：\n\n\tvar memory = new client.Realtime('Memory');\n\n### incr\n`incr`方法用来递增实例的值，如增加当前内存占用的空间：\n\n\tmemory.incr(1, function (err, result) {\n\t\tconsole.log('当前内存占用为：' + result);\n\t});\n\n其中第一个参数表示增加的数量，如果省略则默认为1。\n\n### set\n`set`方法用来设置实例的值，如：\n\n\tmemory.set(20);\n\n### get\n`get`方法用来获得实例的值，如：\n\n\tmemory.get(function (err, result) {\n\t\tconsole.log('当前内存占用为：' + result);\n\t});\n\n### 实时通知\n当修改了某个Realtime实例的值后，ranaly会使用Redis的`PUBLISH`命令派发通知，`channel`可以通过实例的`channel`属性获得，如：\n\n\tvar sub = redis.createClient();\n\tsub.subscribe(memory.channel);\n\tsub.on('message', function (channel, message) {\n\t\tif (channel === memory.channel) {\n\t\t\tconsole.log('当前内存占用为：' + message);\n\t\t}\n\t});\n\n## DataList\n创建一个DataList实例：\n\n\tvar userAvatars = new client.DataList('Avatars');\n\n### push\n`push`方法用来向实例加入一个元素，可以是字符串、数组、数组或对象类型，如：\n\n\tuserAvatars.push({\n\t\turl: 'http://demo.com/avatar.png',\n\t\tuserID: 17\n\t}, 50, function (err, length) {\n\t});\n\n其中第二个参数表示保留的记录数量，默认为100。\n\n### len\n`len`方法用来获得实例的大小，如：\n\n\tuserAvatars.len(function (err, length) {\n\t});\n\n### range\n`range`方法用来获得队列中的某个片段，第一个参数表示起始元素索引，第二个元素表示末尾元素索引。索引从0开始，支持负索引，即-1表示队列中最后一个元素。如：\n\n\tuserAvatars.range(0, -1, function (err, avatars) {\n\t\tavatars.forEach(function (avatar) {\n\t\t\tconsole.log(avatar.url);\n\t\t});\n\t});\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluin%2Fnode_ranaly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluin%2Fnode_ranaly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluin%2Fnode_ranaly/lists"}