Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

timekeeper

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timekeeper

Easy testing of time-dependent code.

  • 0.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
160K
decreased by-22.14%
Maintainers
3
Weekly downloads
 
Created

What is timekeeper?

The timekeeper npm package allows developers to manipulate and control the flow of time in their Node.js applications. This is particularly useful for testing time-dependent code, such as scheduling, timeouts, and date-based logic.

What are timekeeper's main functionalities?

Freeze Time

This feature allows you to freeze the current time to a specific date. This is useful for testing code that depends on the current date and time.

const timekeeper = require('timekeeper');
const frozenDate = new Date(2020, 0, 1);
timekeeper.freeze(frozenDate);
// Your code here will think the current date is January 1, 2020
timekeeper.reset(); // Reset to the real current date

Travel in Time

This feature allows you to travel to a specific date in the future or past. This is useful for testing how your code behaves at different points in time.

const timekeeper = require('timekeeper');
const futureDate = new Date(2025, 0, 1);
timekeeper.travel(futureDate);
// Your code here will think the current date is January 1, 2025
timekeeper.reset(); // Reset to the real current date

Reset Time

This feature allows you to reset the time back to the real current date and time. This is useful for cleaning up after tests that manipulate time.

const timekeeper = require('timekeeper');
timekeeper.reset();
// Your code here will use the real current date and time

Other packages similar to timekeeper

Keywords

FAQs

Package last updated on 03 Nov 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc