gustavla
gustavla

Reputation: 42

Importing NPM package to Meteor with a hyphen/dash (streaker-js)

I am trying to import the npm package streaker-js into my Meteor app, but I think there is a problem with it having a dash/hyphen in the name.

Installing it with

meteor npm install --save streaker-js

is fine.

But when trying to import in the client side code with

import streaker-js from 'streaker-js';

I get an error:

=> Errors prevented startup:                   

   While processing files with ecmascript (for target web.browser):
   client/main.js:4:15: Unexpected token (4:15)

=> Your application has errors. Waiting for file change.

My reasoning is that there is an issue with importing NPM packages that has a dash in the name.

So, how would you import streaker-js into Meteor?

Upvotes: 0

Views: 554

Answers (1)

rkstar
rkstar

Reputation: 1220

javascript variables can't have a hyphen in them. try this:

import streaker from 'streaker-js'

// Assuming the date is currently new Date(2012, 6, 8) : 
var dates = [ new Date(2012, 6, 6), new Date(2012, 6, 7), new Date(2012, 6, 8) ];
var currentStreak = streaker(dates).current(); // 3 

var datesWithoutToday = [ new Date(2012, 6, 6), new Date(2012, 6, 7) ];
var currentStreak = streaker(datesWithoutToday).current(); // 2 - the streak isn't broken until the end of the day 

var datesWithoutTodayOrYesterday = [ new Date(2012, 6, 6) ];
var currentStreak = streaker(datesWithoutTodayOrYesterday).current(); // 0 - the streak is broken as of today 

Upvotes: 2

Related Questions