New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@date/holidays

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@date/holidays - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

138

lib/index.js
// Generated by CoffeeScript 1.10.0
var calculateHolidays, generators, holidays, ops, storeHoliday,
var Holidays,
slice = [].slice;
holidays = {};
generators = [];
storeHoliday = function(holiday, year) {
var base, name;
if ((base = holidays[year])[name = holiday.date.month] == null) {
base[name] = {};
Holidays = (function() {
function Holidays() {
this.holidays = {};
this.generators = [];
}
holidays[year][holiday.date.month][holiday.date.day] = holiday.info;
};
calculateHolidays = function(year) {
var generate, holiday, i, len, result, results;
if (holidays[year] != null) {
return;
}
holidays[year] = {};
results = [];
for (i = 0, len = generators.length; i < len; i++) {
generate = generators[i];
result = generate(year);
if (Array.isArray(result)) {
results.push((function() {
var j, len1, results1;
results1 = [];
for (j = 0, len1 = result.length; j < len1; j++) {
holiday = result[j];
results1.push(storeHoliday(holiday, year));
}
return results1;
})());
} else {
results.push(storeHoliday(result, year));
Holidays.prototype._storeHoliday = function(holiday, year) {
var base, name;
if ((base = this.holidays[year])[name = holiday.date.month] == null) {
base[name] = {};
}
}
return results;
};
this.holidays[year][holiday.date.month][holiday.date.day] = holiday.info;
};
module.exports = ops = {
calculateHolidays: calculateHolidays,
isHoliday: function(arg1, arg2) {
Holidays.prototype._calculateHolidays = function(year) {
var generate, holiday, i, len, ref, result, results;
if (this.holidays[year] != null) {
return;
}
this.holidays[year] = {};
ref = this.generators;
results = [];
for (i = 0, len = ref.length; i < len; i++) {
generate = ref[i];
result = generate(year);
if (Array.isArray(result)) {
results.push((function() {
var j, len1, results1;
results1 = [];
for (j = 0, len1 = result.length; j < len1; j++) {
holiday = result[j];
results1.push(this._storeHoliday(holiday, year));
}
return results1;
}).call(this));
} else {
results.push(this._storeHoliday(result, year));
}
}
return results;
};
Holidays.prototype.isHoliday = function(arg1, arg2) {
var holiday;
holiday = ops.getHoliday(arg1, arg2);
holiday = this.getHoliday(arg1, arg2);
return holiday != null;
},
getHoliday: function(arg1, arg2) {
};
Holidays.prototype.getHoliday = function(arg1, arg2) {
var date, holiday, key, month, options, ref, ref1, value, year;

@@ -68,4 +70,4 @@ if (arg1 instanceof Date) {

month = date.getMonth();
ops.calculateHolidays(year);
holiday = (ref = holidays[year]) != null ? (ref1 = ref[month]) != null ? ref1[date.getDate()] : void 0 : void 0;
this._calculateHolidays(year);
holiday = (ref = this.holidays[year]) != null ? (ref1 = ref[month]) != null ? ref1[date.getDate()] : void 0 : void 0;
if (holiday == null) {

@@ -85,4 +87,5 @@ return null;

return holiday;
},
purge: function() {
};
Holidays.prototype.purge = function() {
var i, len, year, years;

@@ -96,13 +99,15 @@ years = 1 <= arguments.length ? slice.call(arguments, 0) : [];

year = years[i];
delete holidays[year];
delete this.holidays[year];
}
} else {
holidays = {};
this.holidays = {};
}
},
add: function(generator) {
var date, fn, i, info, len;
};
Holidays.prototype.add = function(generator) {
var date, fn, i, info, len, ref;
if (typeof generator === 'function') {
for (i = 0, len = generators.length; i < len; i++) {
fn = generators[i];
ref = this.generators;
for (i = 0, len = ref.length; i < len; i++) {
fn = ref[i];
if (fn === generator) {

@@ -125,11 +130,13 @@ return generator;

}
generators.push(generator);
this.generators.push(generator);
return generator;
},
remove: function(generator) {
var fn, i, index, len;
for (index = i = 0, len = generators.length; i < len; index = ++i) {
fn = generators[index];
};
Holidays.prototype.remove = function(generator) {
var fn, i, index, len, ref;
ref = this.generators;
for (index = i = 0, len = ref.length; i < len; index = ++i) {
fn = ref[index];
if (fn === generator) {
generators.splice(index, 1);
this.generators.splice(index, 1);
return true;

@@ -139,3 +146,12 @@ }

return false;
}
};
return Holidays;
})();
module.exports = function() {
return new Holidays;
};
exports.Holidays = Holidays;
{
"name": "@date/holidays",
"version": "0.1.0",
"version": "0.2.0",
"description": "Store and compare holiday dates",

@@ -5,0 +5,0 @@ "main": "lib",

@@ -20,5 +20,5 @@ # @date/holidays

var Holidays = require('@date/holidays')
var holidays = Holidays()
// all in one: var holidays = require('@date/holidays')()
var holidays = new Holidays()
// at this point `holidays` is empty so all calls to isHoliday() return false.

@@ -25,0 +25,0 @@

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