{"_id":"@ad-execute-manager/count-recorder","_rev":"4-bdde5719081027dc22f7332e9116d94b","name":"@ad-execute-manager/count-recorder","dist-tags":{"latest":"2.1.0"},"versions":{"2.0.1":{"name":"@ad-execute-manager/count-recorder","version":"2.0.1","keywords":["logger","logging","utility","javascript","nodejs","typescript","log-levels","debug"],"author":{"url":"https://github.com/singcl","name":"singcl","email":"iambabyer@gmail.com"},"license":"MIT","_id":"@ad-execute-manager/count-recorder@2.0.1","maintainers":[{"name":"singcl","email":"24661881@qq.com"}],"homepage":"https://npmjs.com/package/@ad-execute-manager/logger","bugs":{"url":"https://github.com/singcl/ad-execute-manager/issues"},"dist":{"shasum":"4cd329098784f7eef0f8b515845ef3816281ee4a","tarball":"https://registry.npmjs.org/@ad-execute-manager/count-recorder/-/count-recorder-2.0.1.tgz","fileCount":7,"integrity":"sha512-pjF+fes3oTzS0+B7UIQydX66lzPkvuuOU6U8LEqx0ZfxzK18/daHJmJ/FefNRH0sAnFAOnF9mUlsieXwsFzIaw==","signatures":[{"sig":"MEYCIQDTIeviix1bxQjp0G9dTsYkvKyaq+/olISUyznfRpLuuQIhAOf4HGbmu/wpYjvkGAZYYqisDhMyluAuz7FZLgud/D8x","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14299},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","engines":{"node":">=14.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"f4346b3b4a54ac0a1502aeed3177eb12c50ec0ad","scripts":{"dev":"rslib build --watch","lint":"eslint .","test":"rstest","build":"rslib build && tsc","format":"prettier --write .","prepublishOnly":"npm run build"},"_npmUser":{"name":"singcl","email":"24661881@qq.com"},"repository":{"url":"git+https://github.com/singcl/ad-execute-manager.git","type":"git","directory":"packages/logger"},"_npmVersion":"8.5.0","description":"A flexible count recorder utility for JavaScript applications with multiple count recorder adapters and customizable options.","directories":{},"_nodeVersion":"16.14.2","_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.39.2","globals":"^16.5.0","prettier":"^3.7.3","@eslint/js":"^9.39.1","typescript":"^5.9.3","@rslib/core":"^0.18.5","@rstest/core":"^0.7.2","@babel/preset-env":"^7.28.5","@babel/eslint-parser":"^7.28.5","eslint-plugin-import":"^2.32.0"},"peerDependencies":{"@ad-execute-manager/storage":"^2.0.1"},"_npmOperationalInternal":{"tmp":"tmp/count-recorder_2.0.1_1770779184617_0.22422835162833765","host":"s3://npm-registry-packages-npm-production"}},"2.0.2":{"name":"@ad-execute-manager/count-recorder","version":"2.0.2","keywords":["count-recorder","counter","daily-tracker","usage-limit","javascript","nodejs","typescript","storage","user-specific","expiration"],"author":{"url":"https://github.com/singcl","name":"singcl","email":"iambabyer@gmail.com"},"license":"MIT","_id":"@ad-execute-manager/count-recorder@2.0.2","maintainers":[{"name":"singcl","email":"24661881@qq.com"}],"homepage":"https://npmjs.com/package/@ad-execute-manager/count-recorder","bugs":{"url":"https://github.com/singcl/ad-execute-manager/issues"},"dist":{"shasum":"202eaa35fe74125a38d3abc79d60985d7aad2c91","tarball":"https://registry.npmjs.org/@ad-execute-manager/count-recorder/-/count-recorder-2.0.2.tgz","fileCount":7,"integrity":"sha512-AST5A4XoGJFj0t25JRNV+soqenZu+sKCaO13M32/Ncuuq1K6vpH/ArfyFs7erMjJmCIyeHWq91J+shCMjjJObQ==","signatures":[{"sig":"MEUCIAX9G+Z7KTn9r4k57qPzCqnWCYjM3wRVNmYarBWtmbhxAiEAhT7t3cW6w/+NtTibkGLafXVWE2QEZndNL1wiCoiU/9w=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14376},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","engines":{"node":">=14.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"125db4b0802b729880f057231b20f8a8c8596663","scripts":{"dev":"rslib build --watch","lint":"eslint .","test":"rstest","build":"rslib build && tsc","format":"prettier --write .","prepublishOnly":"npm run build"},"_npmUser":{"name":"singcl","email":"24661881@qq.com"},"repository":{"url":"git+https://github.com/singcl/ad-execute-manager.git","type":"git","directory":"packages/count-recorder"},"_npmVersion":"8.5.0","description":"A flexible count recorder utility for JavaScript applications with daily tracking, expiration support, and user-specific counting.","directories":{},"_nodeVersion":"16.14.2","_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.39.2","globals":"^16.5.0","prettier":"^3.7.3","@eslint/js":"^9.39.1","typescript":"^5.9.3","@rslib/core":"^0.18.5","@rstest/core":"^0.7.2","@babel/preset-env":"^7.28.5","@babel/eslint-parser":"^7.28.5","eslint-plugin-import":"^2.32.0"},"peerDependencies":{"@ad-execute-manager/storage":"^2.0.1"},"_npmOperationalInternal":{"tmp":"tmp/count-recorder_2.0.2_1770781380636_0.14834197415694295","host":"s3://npm-registry-packages-npm-production"}},"2.0.5":{"name":"@ad-execute-manager/count-recorder","version":"2.0.5","keywords":["count-recorder","counter","daily-tracker","usage-limit","javascript","nodejs","typescript","storage","user-specific","expiration"],"author":{"url":"https://github.com/singcl","name":"singcl","email":"iambabyer@gmail.com"},"license":"MIT","_id":"@ad-execute-manager/count-recorder@2.0.5","maintainers":[{"name":"singcl","email":"24661881@qq.com"}],"homepage":"https://npmjs.com/package/@ad-execute-manager/count-recorder","bugs":{"url":"https://github.com/singcl/ad-execute-manager/issues"},"dist":{"shasum":"27e2ad21515349091c6f6694cba8e1923d3baa3c","tarball":"https://registry.npmjs.org/@ad-execute-manager/count-recorder/-/count-recorder-2.0.5.tgz","fileCount":7,"integrity":"sha512-3ZHSeHsGkXhJ3MJDAZY3nsl6wtrOohn9i7dKpx6pF+wLtJGIz34BiiF7g/1fGirTeIlZxlWVoVi6bdZOs9qwEQ==","signatures":[{"sig":"MEUCIA7OutkLv5LEjBK8r4uKNgVdYm6IlWNHUzyaw2n6P0n/AiEAp5NPOzI5+CRkPBFjKb/fgnNcb8O1uvLhpS74748xibI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14385},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","engines":{"node":">=14.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"496539214dcaa933fcb20441d4962601c22045b9","scripts":{"dev":"rslib build --watch","lint":"eslint .","test":"rstest","build":"rslib build && tsc","format":"prettier --write .","prepublishOnly":"npm i && npm run build"},"_npmUser":{"name":"singcl","email":"24661881@qq.com"},"repository":{"url":"git+https://github.com/singcl/ad-execute-manager.git","type":"git","directory":"packages/count-recorder"},"_npmVersion":"8.5.0","description":"A flexible count recorder utility for JavaScript applications with daily tracking, expiration support, and user-specific counting.","directories":{},"_nodeVersion":"16.14.2","_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.39.2","globals":"^16.5.0","prettier":"^3.7.3","@eslint/js":"^9.39.1","typescript":"^5.9.3","@rslib/core":"^0.18.5","@rstest/core":"^0.7.2","@babel/preset-env":"^7.28.5","@babel/eslint-parser":"^7.28.5","eslint-plugin-import":"^2.32.0"},"peerDependencies":{"@ad-execute-manager/storage":"^2.0.5"},"_npmOperationalInternal":{"tmp":"tmp/count-recorder_2.0.5_1770859125964_0.9546684943181454","host":"s3://npm-registry-packages-npm-production"}},"2.1.0":{"name":"@ad-execute-manager/count-recorder","version":"2.1.0","description":"A flexible count recorder utility for JavaScript applications with daily tracking, expiration support, and user-specific counting.","type":"module","exports":{".":{"import":"./dist/index.js","require":"./dist/index.cjs","types":"./dist/index.d.ts"}},"main":"./dist/index.cjs","types":"./dist/index.d.ts","author":{"name":"singcl","email":"iambabyer@gmail.com","url":"https://github.com/singcl"},"license":"MIT","homepage":"https://npmjs.com/package/@ad-execute-manager/count-recorder","repository":{"type":"git","url":"git+https://github.com/singcl/ad-execute-manager.git","directory":"packages/count-recorder"},"bugs":{"url":"https://github.com/singcl/ad-execute-manager/issues"},"engines":{"node":">=14.0.0"},"keywords":["count-recorder","counter","daily-tracker","usage-limit","javascript","nodejs","typescript","storage","user-specific","expiration"],"scripts":{"build":"rslib build && tsc","dev":"rslib build --watch","format":"prettier --write .","lint":"eslint .","test":"rstest","prepublishOnly":"npm i && npm run build"},"peerDependencies":{"@ad-execute-manager/storage":"^2.1.0"},"devDependencies":{"@babel/eslint-parser":"^7.28.5","@babel/preset-env":"^7.28.5","@eslint/js":"^9.39.1","@rslib/core":"^0.18.5","@rstest/core":"^0.7.2","eslint":"^9.39.2","eslint-plugin-import":"^2.32.0","globals":"^16.5.0","prettier":"^3.7.3","typescript":"^5.9.3"},"_id":"@ad-execute-manager/count-recorder@2.1.0","gitHead":"340826aa12d7a20b8d516584dc2124908c9e7f0b","_nodeVersion":"22.21.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-XEMardbaCpbeKrfF2eC7BCQTtjH3GZAoInr3TyqFRm38WaNwszGxMJlY0gBzu15OZXcvasubcDM+J4+Toon39g==","shasum":"6c2428131adbc242961b88902e0d82e039388a39","tarball":"https://registry.npmjs.org/@ad-execute-manager/count-recorder/-/count-recorder-2.1.0.tgz","fileCount":7,"unpackedSize":15504,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDelJZM24Zi5T64gf8GaXksnpNzLDXIUxn/SLPf+qNCuQIhAOa5iC6QPLc9+ulf8MuDKaKXc41YiyxxtX6M+SNwaYD3"}]},"_npmUser":{"name":"singcl","email":"24661881@qq.com"},"directories":{},"maintainers":[{"name":"singcl","email":"24661881@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/count-recorder_2.1.0_1772177633458_0.7401765691487785"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-11T03:06:24.394Z","modified":"2026-02-27T07:33:53.823Z","2.0.1":"2026-02-11T03:06:24.769Z","2.0.2":"2026-02-11T03:43:00.793Z","2.0.5":"2026-02-12T01:18:46.113Z","2.1.0":"2026-02-27T07:33:53.687Z"},"bugs":{"url":"https://github.com/singcl/ad-execute-manager/issues"},"author":{"name":"singcl","email":"iambabyer@gmail.com","url":"https://github.com/singcl"},"license":"MIT","homepage":"https://npmjs.com/package/@ad-execute-manager/count-recorder","keywords":["count-recorder","counter","daily-tracker","usage-limit","javascript","nodejs","typescript","storage","user-specific","expiration"],"repository":{"type":"git","url":"git+https://github.com/singcl/ad-execute-manager.git","directory":"packages/count-recorder"},"description":"A flexible count recorder utility for JavaScript applications with daily tracking, expiration support, and user-specific counting.","maintainers":[{"name":"singcl","email":"24661881@qq.com"}],"readme":"# @ad-execute-manager/count-recorder\r\n\r\nA flexible count recorder utility for JavaScript applications with daily tracking, expiration support, and user-specific counting.\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install @ad-execute-manager/count-recorder\r\n```\r\n\r\n## Features\r\n\r\n- **Daily Count Tracking**: Track counts on a daily basis with automatic reset\r\n- **Expiration Support**: Set expiration times for count data, including 'today' option\r\n- **User-specific Counting**: Track counts per user with automatic userId integration\r\n- **Storage Integration**: Uses @ad-execute-manager/storage for persistent storage\r\n- **Total Count Management**: Set and manage total count limits\r\n- **Remaining Count Calculation**: Automatically calculate remaining counts\r\n- **TypeScript Support**: Includes TypeScript type definitions\r\n- **Error Handling**: Built-in error handling for required parameters\r\n\r\n## Usage\r\n\r\n### Basic Usage\r\n\r\n```javascript\r\nimport { CountRecorder } from '@ad-execute-manager/count-recorder';\r\n\r\n// Create a count recorder instance\r\nconst dailyTaskRecorder = CountRecorder.new({\r\n  local_sign: 'daily_task_recorder',\r\n  total: 5, // Maximum 5 times per day\r\n  expire: 'today', // Reset daily\r\n  userId: 'user123' // User-specific counting\r\n});\r\n\r\n// Check remaining counts\r\nconst remaining = dailyTaskRecorder.remain();\r\nconsole.log('Remaining tasks:', remaining);\r\n\r\nif (remaining > 0) {\r\n  // Perform the task\r\n  console.log('Performing task...');\r\n  \r\n  // Update the count\r\n  dailyTaskRecorder.updateToday();\r\n  \r\n  console.log('Task performed, count updated');\r\n} else {\r\n  console.log('Daily limit reached');\r\n}\r\n```\r\n\r\n### Advanced Usage\r\n\r\n```javascript\r\nimport { CountRecorder } from '@ad-execute-manager/count-recorder';\r\n\r\n// Create multiple recorders for different purposes\r\n\r\n// Daily ad impression recorder\r\nconst adRecorder = CountRecorder.new({\r\n  local_sign: 'ad_impression_recorder',\r\n  total: 10, // Maximum 10 ads per day\r\n  expire: 'today',\r\n  userId: 'user123'\r\n});\r\n\r\n// Weekly feature usage recorder\r\nconst featureRecorder = CountRecorder.new({\r\n  local_sign: 'feature_usage_recorder',\r\n  total: 20, // Maximum 20 uses per week\r\n  expire: 7 * 24 * 60 * 60 * 1000, // 7 days expiration\r\n  userId: 'user123'\r\n});\r\n\r\n// Check and use ad impressions\r\nfunction showAd() {\r\n  const remaining = adRecorder.remain();\r\n  \r\n  if (remaining > 0) {\r\n    console.log('Showing ad...');\r\n    adRecorder.updateToday();\r\n    console.log('Ad shown, remaining:', adRecorder.remain());\r\n    return true;\r\n  } else {\r\n    console.log('Ad limit reached for today');\r\n    return false;\r\n  }\r\n}\r\n\r\n// Check and use feature\r\nfunction usePremiumFeature() {\r\n  const remaining = featureRecorder.remain();\r\n  \r\n  if (remaining > 0) {\r\n    console.log('Using premium feature...');\r\n    featureRecorder.updateToday();\r\n    console.log('Feature used, remaining:', featureRecorder.remain());\r\n    return true;\r\n  } else {\r\n    console.log('Feature usage limit reached');\r\n    return false;\r\n  }\r\n}\r\n\r\n// Usage examples\r\n// showAd();\r\n// usePremiumFeature();\r\n```\r\n\r\n## API\r\n\r\n### Constructor\r\n\r\n```javascript\r\nnew CountRecorder(args)\r\n```\r\n\r\n- **args** (Object): Configuration arguments\r\n  - **local_sign** (String): Local storage identifier (required)\r\n  - **total** (Number): Total count limit, defaults to 0\r\n  - **expire** (Number|'today'): Expiration time in milliseconds or 'today' for day-bound, defaults to 'today'\r\n  - **userId** (String|Number): User ID for user-specific counting\r\n\r\n### Methods\r\n\r\n- **remain()**: Get remaining count\r\n  - **returns** (Number): Remaining count\r\n\r\n- **updateToday()**: Update today's count\r\n\r\n### Static Methods\r\n\r\n- **CountRecorder.new(args)**: Create a new CountRecorder instance\r\n  - **args** (Object): Same as constructor arguments\r\n  - **returns** (CountRecorder): New CountRecorder instance\r\n\r\n## Examples\r\n\r\n### Example 1: Daily Login Tracker\r\n\r\n```javascript\r\nimport { CountRecorder } from '@ad-execute-manager/count-recorder';\r\n\r\n// Create login recorder\r\nconst loginRecorder = CountRecorder.new({\r\n  local_sign: 'daily_login_recorder',\r\n  total: 1, // Only one login count per day\r\n  expire: 'today',\r\n  userId: 'user123'\r\n});\r\n\r\n// Check if user has already logged in today\r\nfunction checkDailyLogin() {\r\n  const remaining = loginRecorder.remain();\r\n  \r\n  if (remaining > 0) {\r\n    console.log('First login today');\r\n    // Give daily login bonus\r\n    giveDailyBonus();\r\n    // Update login count\r\n    loginRecorder.updateToday();\r\n  } else {\r\n    console.log('Already logged in today');\r\n  }\r\n}\r\n\r\n// Give daily bonus\r\nfunction giveDailyBonus() {\r\n  console.log('Giving daily login bonus...');\r\n  // Bonus logic here\r\n}\r\n\r\n// Usage\r\n// checkDailyLogin();\r\n```\r\n\r\n### Example 2: Ad Impression Limiter\r\n\r\n```javascript\r\nimport { CountRecorder } from '@ad-execute-manager/count-recorder';\r\n\r\n// Create ad impression recorder\r\nconst adRecorder = CountRecorder.new({\r\n  local_sign: 'ad_impression_recorder',\r\n  total: 8, // Maximum 8 ads per day\r\n  expire: 'today',\r\n  userId: 'user123'\r\n});\r\n\r\n// Check if ad can be shown\r\nfunction canShowAd() {\r\n  const remaining = adRecorder.remain();\r\n  return remaining > 0;\r\n}\r\n\r\n// Show ad and update count\r\nfunction showAd() {\r\n  if (canShowAd()) {\r\n    console.log('Showing ad...');\r\n    // Ad showing logic here\r\n    adRecorder.updateToday();\r\n    console.log('Ad shown, remaining impressions:', adRecorder.remain());\r\n    return true;\r\n  } else {\r\n    console.log('Ad limit reached for today');\r\n    return false;\r\n  }\r\n}\r\n\r\n// Check remaining ad impressions\r\nfunction checkAdLimit() {\r\n  const remaining = adRecorder.remain();\r\n  console.log(`Remaining ad impressions: ${remaining}/8`);\r\n  return remaining;\r\n}\r\n\r\n// Usage examples\r\n// checkAdLimit();\r\n// showAd();\r\n```\r\n\r\n### Example 3: Feature Usage Tracker\r\n\r\n```javascript\r\nimport { CountRecorder } from '@ad-execute-manager/count-recorder';\r\n\r\n// Create feature usage recorder\r\nconst featureRecorder = CountRecorder.new({\r\n  local_sign: 'premium_feature_recorder',\r\n  total: 15, // Maximum 15 uses per day\r\n  expire: 'today',\r\n  userId: 'user123'\r\n});\r\n\r\n// Use premium feature\r\nfunction usePremiumFeature(featureName) {\r\n  const remaining = featureRecorder.remain();\r\n  \r\n  if (remaining > 0) {\r\n    console.log(`Using premium feature: ${featureName}`);\r\n    // Feature usage logic here\r\n    featureRecorder.updateToday();\r\n    console.log(`Feature used, remaining uses: ${featureRecorder.remain()}/15`);\r\n    return true;\r\n  } else {\r\n    console.log('Premium feature usage limit reached for today');\r\n    return false;\r\n  }\r\n}\r\n\r\n// Check feature usage status\r\nfunction checkFeatureUsage() {\r\n  const remaining = featureRecorder.remain();\r\n  const used = 15 - remaining;\r\n  console.log(`Premium feature usage: ${used}/15 today`);\r\n  return { used, remaining, total: 15 };\r\n}\r\n\r\n// Usage examples\r\n// checkFeatureUsage();\r\n// usePremiumFeature('AI Summarizer');\r\n```\r\n\r\n## Dependencies\r\n\r\n- **@ad-execute-manager/storage**: For persistent storage of count data\r\n\r\n## License\r\n\r\nMIT\r\n","readmeFilename":"README.md"}