0

Here is my code

var foobar  = require('module').foobar()
foobar.useOne()
foobar.useTwo()

I am looking for the ES6 equivalent of the first line (with import ... as ... from) so that i can still do foobar.useOne(), foobar.useTwo() etc
If there is one..

thsr
  • 75
  • 5

1 Answers1

0

Looks like your module exposes a factory method, so you need an intermediate variable to store the foobar instance.

import { foobar as Foobar } from 'module';
const foobar = Foobar();
foobar.useOne();
foobar.useTwo();
Tamas Hegedus
  • 28,755
  • 12
  • 63
  • 97