Skip to content

Commit

Permalink
[WIP] Yarn migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Luthjohn committed May 9, 2018
1 parent edbd5aa commit 3526b9c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
32 changes: 16 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
var _ = require('underscore')._;
var moment = require('moment');
const _ = require('lodash');
const moment = require('moment');

module.exports = function(config) {

var toUTC = function(unixTimestamp) {
const toUTC = function(unixTimestamp) {
//javascript uses milliseconds, not seconds since the epoch.
var timestamp = parseInt(unixTimestamp) * 1000;
var date = moment(timestamp).utc();
const timestamp = parseInt(unixTimestamp) * 1000;
const date = moment(timestamp).utc();
return date.format('YYYYMMDDTHHmmss[Z]')
};

var addLine = function(title, line) {
var buffer = '';
const addLine = function(title, line) {
let buffer = '';

if (line === undefined || line === null) {
return buffer;
Expand All @@ -21,7 +21,7 @@ module.exports = function(config) {
buffer += title + ':' + line.substr(0, 73) + '\r\n';
} else {
buffer += title + ':';
var maxLen = 73 - title.length + 1;
let maxLen = 73 - title.length + 1;

while (line.length >= maxLen) {
//The space the the end of this string is SUPER-IMPORTANT!
Expand All @@ -37,8 +37,8 @@ module.exports = function(config) {
return buffer;
};

var createICS = function(config) {
var buffer = '';
const createICS = function(config) {
let buffer = '';

buffer += addLine('BEGIN', 'VCALENDAR');
buffer += addLine('VERSION', '2.0');
Expand All @@ -57,11 +57,11 @@ module.exports = function(config) {
return buffer;
};

var processJSONEvents = function(events) {
var buffer = '';
const processJSONEvents = function(events) {
let buffer = '';
_.each(events, function(evt) {

var skip = false;
let skip = false;
if (evt.id === undefined) {
console.log('Must Specify a unique id.')
skip = true;
Expand All @@ -80,7 +80,7 @@ module.exports = function(config) {
buffer += addLine('DESCRIPTION', escapeText(evt.description));
buffer += addLine('DTSTAMP', toUTC(moment().unix()));
buffer += addLine('DTSTART', toUTC(evt.start));
if (evt.end == undefined) {
if (evt.end === undefined) {
//If there isn't an end time, assume it's an instantaneous
//event, and have it end one second after it starts.
buffer += addLine('DTEND', toUTC(evt.start + 1));
Expand All @@ -97,8 +97,8 @@ module.exports = function(config) {
return buffer;
};

var escapeText = function(s) {
var t;
const escapeText = function(s) {
let t;
if (s == null) {
return s;
}
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "tm-json-ics",
"description": "Takes simple JSON for events and converts it to an ICS file.",
"version": "1.4.0",
"version": "1.4.1",
"private": true,
"dependencies": {
"moment": "^2.10.2",
"underscore": "^1.8.3"
"moment": "2.22.0",
"lodash": "4.10.0"
},
"engines": {
"node": ">= 0.8.x",
"node": "8.11.1",
"npm": ">= 1.1.x"
}
}
11 changes: 11 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


[email protected]:
version "4.10.0"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.10.0.tgz#3d8f3ac7a5a904fdb01e2cfe1401879bf9652c6a"

[email protected]:
version "2.22.0"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.0.tgz#7921ade01017dd45186e7fee5f424f0b8663a730"

0 comments on commit 3526b9c

Please sign in to comment.