Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
A pure JS parser for natural language repeated events expressions
npm install --save crontalk
Tired of messing with asterisks when scheduling jobs? Crontalk allows you to easily parse natural language expressions such as "every 3 days from next monday" and convert them to a JS object.
const ct = require('crontalk');
let occurrences = ct.parse('every 3 days from the last day of september this year');
console.log(occurrences);
The parser returns a JS object representing the schedule. The object structure depends on the clauses used in the expression.
The first format of the every clause allows you to specify the frequency of repetition. For instance, the expression
every 3 days and 5 hours and 2 minutes
results in the following object:
"span": {
"days": 3,
"hours": 5,
"minutes": 2
}
The from...to construct (Lapse clause) lets you define a time interval during which to apply the rule. The following example:
every three days from the 12th of june 2017 to the 3rd of september 2017
will give you the object:
"span": {
"days": 3,
"lapse": {
"from": {
"day": 12,
"month": 5,
"year": 2017
},
"to": {
"day": 2,
"month": 8,
"year": 2017
}
}
}
You can use constructions such as "the last day of november" or "the second last minute of the fourth hour". The "last" keyword will yield negative values for the related unit of measure (-1 means last, -2 means second last, etc).
The second format of the every clause must be used in conjuntion with a Lapse clause and allows you to specify a condition for the repetition. Consider the following example:
every third january from february 1980 to 1999
this results in:
"span": {
"years": 3,
"lapse": {
"from": {
"year": 1980,
"month": 1
},
"to": {
"year": 1999
}
},
"on": {
"year": 2,
"_month": 0
}
}
Note the "_month" property. The underscore in front of the unit name in the "on" property means that property must be interpreted as an absolute offset, not a relative one. I.E. "_month": 0 always means January, while "month": 0 means the first month of the Lapse clause.
Your can use the keywords "this", "last", "next", and "today", "yesterday", and "tomorrow" in most places when it's appropriate. This will result in the values "this", "last", and "next", being returned instead of a number in the related property of the object.
every 3 days from last year
Will be transformed into:
"span": {
"days": 3,
"lapse": {
"from": {
"year": "last"
}
}
}
Install the package and look at /docs/railroad.html for the railroad diagrams of Crontalk's DSL.
Look at the tests for usage examples.
This package is released under the MIT License
FAQs
A pure JS parser for natural language repeated events expressions
The npm package crontalk receives a total of 4 weekly downloads. As such, crontalk popularity was classified as not popular.
We found that crontalk 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.