
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Calculates the diff between dates and returns a nicely formatted string.
Turns an array of dates into:
npm install --save recurrence
const recurrence = require('recurrence');
const dates = [
new Date(2016, 1, 1),
new Date(2016, 1, 2)
new Date(2016, 1, 3)
];
console.log(recurrence(dates));
Duplicate dates are removed and the order doesn't matter.
{
"count": 1,
"unit": "day/week/month/year",
"recurrence": "Daily"
}
In the output recurrence
is set to something that you could show directly to a user.
Values look like this:
Of course you can use the count
and unit
for your own output, maybe for other languages or otherwise different results.
You can pass an options object as the second argument.
Defaults:
{
"numberAsString": false,
"strict": false,
"noSingleUnits": false
}
Override any of these by passing in an object:
recurrence(dates, {
strict: true,
numberAsString: true
});
Outputs the number as a text:
Throw an exception if an invalid date is detected. With strict = false
just ignores the date.
Doesn't format strings as daily
or yearly
so it returns Every second/hour/month/year
etc instead of daily
or weekly
const recurrence = require('recurrence');
const leapyears = [
new Date(2016, 1, 29),
new Date(2012, 1, 29)
new Date(2008, 1, 29)
];
const result = recurrence(leapyears, {
numberAsString: true
});
console.log(`Leap year happens ${result.recurrence}!`);
// Leap year happens every four years!
npm run test
npm run cover
FAQs
Generates a string based on string recurrence
The npm package recurrence receives a total of 3 weekly downloads. As such, recurrence popularity was classified as not popular.
We found that recurrence demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.