npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ad-execute-manager/count-recorder

v2.1.0

Published

A flexible count recorder utility for JavaScript applications with daily tracking, expiration support, and user-specific counting.

Readme

@ad-execute-manager/count-recorder

A flexible count recorder utility for JavaScript applications with daily tracking, expiration support, and user-specific counting.

Installation

npm install @ad-execute-manager/count-recorder

Features

  • Daily Count Tracking: Track counts on a daily basis with automatic reset
  • Expiration Support: Set expiration times for count data, including 'today' option
  • User-specific Counting: Track counts per user with automatic userId integration
  • Storage Integration: Uses @ad-execute-manager/storage for persistent storage
  • Total Count Management: Set and manage total count limits
  • Remaining Count Calculation: Automatically calculate remaining counts
  • TypeScript Support: Includes TypeScript type definitions
  • Error Handling: Built-in error handling for required parameters

Usage

Basic Usage

import { CountRecorder } from '@ad-execute-manager/count-recorder';

// Create a count recorder instance
const dailyTaskRecorder = CountRecorder.new({
  local_sign: 'daily_task_recorder',
  total: 5, // Maximum 5 times per day
  expire: 'today', // Reset daily
  userId: 'user123' // User-specific counting
});

// Check remaining counts
const remaining = dailyTaskRecorder.remain();
console.log('Remaining tasks:', remaining);

if (remaining > 0) {
  // Perform the task
  console.log('Performing task...');
  
  // Update the count
  dailyTaskRecorder.updateToday();
  
  console.log('Task performed, count updated');
} else {
  console.log('Daily limit reached');
}

Advanced Usage

import { CountRecorder } from '@ad-execute-manager/count-recorder';

// Create multiple recorders for different purposes

// Daily ad impression recorder
const adRecorder = CountRecorder.new({
  local_sign: 'ad_impression_recorder',
  total: 10, // Maximum 10 ads per day
  expire: 'today',
  userId: 'user123'
});

// Weekly feature usage recorder
const featureRecorder = CountRecorder.new({
  local_sign: 'feature_usage_recorder',
  total: 20, // Maximum 20 uses per week
  expire: 7 * 24 * 60 * 60 * 1000, // 7 days expiration
  userId: 'user123'
});

// Check and use ad impressions
function showAd() {
  const remaining = adRecorder.remain();
  
  if (remaining > 0) {
    console.log('Showing ad...');
    adRecorder.updateToday();
    console.log('Ad shown, remaining:', adRecorder.remain());
    return true;
  } else {
    console.log('Ad limit reached for today');
    return false;
  }
}

// Check and use feature
function usePremiumFeature() {
  const remaining = featureRecorder.remain();
  
  if (remaining > 0) {
    console.log('Using premium feature...');
    featureRecorder.updateToday();
    console.log('Feature used, remaining:', featureRecorder.remain());
    return true;
  } else {
    console.log('Feature usage limit reached');
    return false;
  }
}

// Usage examples
// showAd();
// usePremiumFeature();

API

Constructor

new CountRecorder(args)
  • args (Object): Configuration arguments
    • local_sign (String): Local storage identifier (required)
    • total (Number): Total count limit, defaults to 0
    • expire (Number|'today'): Expiration time in milliseconds or 'today' for day-bound, defaults to 'today'
    • userId (String|Number): User ID for user-specific counting

Methods

  • remain(): Get remaining count

    • returns (Number): Remaining count
  • updateToday(): Update today's count

Static Methods

  • CountRecorder.new(args): Create a new CountRecorder instance
    • args (Object): Same as constructor arguments
    • returns (CountRecorder): New CountRecorder instance

Examples

Example 1: Daily Login Tracker

import { CountRecorder } from '@ad-execute-manager/count-recorder';

// Create login recorder
const loginRecorder = CountRecorder.new({
  local_sign: 'daily_login_recorder',
  total: 1, // Only one login count per day
  expire: 'today',
  userId: 'user123'
});

// Check if user has already logged in today
function checkDailyLogin() {
  const remaining = loginRecorder.remain();
  
  if (remaining > 0) {
    console.log('First login today');
    // Give daily login bonus
    giveDailyBonus();
    // Update login count
    loginRecorder.updateToday();
  } else {
    console.log('Already logged in today');
  }
}

// Give daily bonus
function giveDailyBonus() {
  console.log('Giving daily login bonus...');
  // Bonus logic here
}

// Usage
// checkDailyLogin();

Example 2: Ad Impression Limiter

import { CountRecorder } from '@ad-execute-manager/count-recorder';

// Create ad impression recorder
const adRecorder = CountRecorder.new({
  local_sign: 'ad_impression_recorder',
  total: 8, // Maximum 8 ads per day
  expire: 'today',
  userId: 'user123'
});

// Check if ad can be shown
function canShowAd() {
  const remaining = adRecorder.remain();
  return remaining > 0;
}

// Show ad and update count
function showAd() {
  if (canShowAd()) {
    console.log('Showing ad...');
    // Ad showing logic here
    adRecorder.updateToday();
    console.log('Ad shown, remaining impressions:', adRecorder.remain());
    return true;
  } else {
    console.log('Ad limit reached for today');
    return false;
  }
}

// Check remaining ad impressions
function checkAdLimit() {
  const remaining = adRecorder.remain();
  console.log(`Remaining ad impressions: ${remaining}/8`);
  return remaining;
}

// Usage examples
// checkAdLimit();
// showAd();

Example 3: Feature Usage Tracker

import { CountRecorder } from '@ad-execute-manager/count-recorder';

// Create feature usage recorder
const featureRecorder = CountRecorder.new({
  local_sign: 'premium_feature_recorder',
  total: 15, // Maximum 15 uses per day
  expire: 'today',
  userId: 'user123'
});

// Use premium feature
function usePremiumFeature(featureName) {
  const remaining = featureRecorder.remain();
  
  if (remaining > 0) {
    console.log(`Using premium feature: ${featureName}`);
    // Feature usage logic here
    featureRecorder.updateToday();
    console.log(`Feature used, remaining uses: ${featureRecorder.remain()}/15`);
    return true;
  } else {
    console.log('Premium feature usage limit reached for today');
    return false;
  }
}

// Check feature usage status
function checkFeatureUsage() {
  const remaining = featureRecorder.remain();
  const used = 15 - remaining;
  console.log(`Premium feature usage: ${used}/15 today`);
  return { used, remaining, total: 15 };
}

// Usage examples
// checkFeatureUsage();
// usePremiumFeature('AI Summarizer');

Dependencies

  • @ad-execute-manager/storage: For persistent storage of count data

License

MIT