how to Instantiate dynamically object with string in node

330
November 25, 2016, at 10:06 PM

I have created a method which create dynamic object from string and it work fine. But I don't understand why when I export my hl7 class it not work anymore... ? How I can fix that ?

   // import hl7 from './hl7/index.js'
    import config from '../../ods/config.json'
    export default class hl7 {
      getLastName() {
        console.log(`===> Dynamic call OK`)
      }
    }
    export default class Encoder {
      constructor(config) {
        this._dynObj = this._setDynamicEncoder(config.format)
        this._message = null
      }
      get message() {
        return this._message;
      }
      set message(message) {
        this._message = message;
      }
      _setDynamicEncoder(format) {
        let obj = eval(`new ${format}()`)
        return obj.getLastName()
      }
    }
    new Encoder(config)

When I import my hl7 class from an other file with "require" or "import" function it not work anymore...

Thanks you!

READ ALSO
Angular-CLI: How to refer to .js from node_modules in <script>-Tag?

Angular-CLI: How to refer to .js from node_modules in <script>-Tag?

For IE11-compatibility, I read here that one should add <script src="node_modules/core-js/client/shimmin

419
request-promise in node not working as expected

request-promise in node not working as expected

I am using request-promise node moduleI have been following the docs, and believe I should have set everything up correctly, however, I am getting the following error:

687
Reading from a piped stream

Reading from a piped stream

I am trying to figure out the best way to read from a piped streamBasically, I have a file on my computer that I would like to read from, pipe it through a crypto cipher and then upload it to an endpoint

318
Log another user out in Node.js Session

Log another user out in Node.js Session

I have a client & APIThe client allows an Admin to log in, which is authenticated by the API, who can then update the permissions of another user

267