Skip to content

fs.promises API is working but why  #25435

Closed
@fxdave

Description

@fxdave
  • Version: v10.15.0
  • Platform: Linux dbiro 4.20.0-arch1-1-ARCH deps: update openssl to 1.0.1j #1 SMP PREEMPT Mon Dec 24 03:00:40 UTC 2018 x86_64 GNU/Linux
  • Subsystem: filesystem

Details:

electron-userland/electron-webpack#255

In short:

Here it is the implementation of getOptions:

function getOptions(options, defaultOptions) {
  if (options === null || options === undefined ||
      typeof options === 'function') {
    return defaultOptions;
  }

  if (typeof options === 'string') {
    defaultOptions = util._extend({}, defaultOptions);
    defaultOptions.encoding = options;
    options = defaultOptions;
  } else if (typeof options !== 'object') {
    throw new ERR_INVALID_ARG_TYPE('options', ['string', 'Object'], options);
  }

  if (options.encoding !== 'buffer')
    assertEncoding(options.encoding);
  return options;
}

But this code is working:

const fsp = require('fs')
fsp.readFile(SOME_VALID_URL, { encoding: 'utf8' })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions