Skip to content

Commit

Permalink
build: tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Dec 22, 2023
1 parent 30982d0 commit 0f1150e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"name": "@microlink/ua",
"description": "A simple redis primitives to incr() and top() user agents",
"homepage": "https://github.com/microlinkhq/ua",
"version": "0.0.0",
"main": "src/index.js",
"version": "0.0.2",
"author": {
"name": "microlink.io",
"email": "[email protected]",
"url": "https://microlink.io"
},
"main": "src/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/microlinkhq/ua.git"
Expand All @@ -18,7 +18,6 @@
},
"keywords": [],
"devDependencies": {
"ioredis": "latest",
"@commitlint/cli": "latest",
"@commitlint/config-conventional": "latest",
"@ksmithut/prettier-standard": "latest",
Expand All @@ -28,6 +27,7 @@
"conventional-github-releaser": "latest",
"finepack": "latest",
"git-authors-cli": "latest",
"ioredis": "latest",
"nano-staged": "latest",
"npm-check-updates": "latest",
"simple-git-hooks": "latest",
Expand Down Expand Up @@ -59,9 +59,6 @@
"@commitlint/config-conventional"
]
},
"exports": {
".": "./src/index.js"
},
"nano-staged": {
"*.js": [
"prettier-standard",
Expand All @@ -77,5 +74,8 @@
"simple-git-hooks": {
"commit-msg": "npx commitlint --edit",
"pre-commit": "npx nano-staged"
},
"dependencies": {
"ua-parser-js": "~1.0.37"
}
}
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
'use strict'

module.exports = client => {
const incr = userAgent => client.zincrby('user_agents', 1, userAgent)
module.exports = redis => {
const incr = userAgent =>
userAgent && redis.zincrby('user_agents', 1, userAgent)

const top = async (n = 10, { withScore = false } = {}) => {
const args = ['user_agents', 0, n - 1, 'REV']
if (withScore) args.push('WITHSCORES')
const range = await client.zrange(...args)
const range = await redis.zrange(...args)

return range.reduce((acc, val, index) => {
if (withScore) {
Expand Down

0 comments on commit 0f1150e

Please sign in to comment.