Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@wrote/exists

wrote3.7kMIT1.0.5

Check If The File Or Directory Exists, And Return Stats.

exists, wrote

readme

@wrote/exists

npm version

@wrote/exists Checks If The File Or Directory Exists, And Return Stats.

yarn add -E @wrote/exists

Table Of Contents

API

The package is available by importing its default function:

import exists from '@wrote/exists'

async exists(
  path: string,
): boolean

Returns whether the path exists or not. If it exists, returns the lstat result, otherwise returns null.

/* yarn example/ */
import exists from '@wrote/exists'

(async () => {
  const res = await exists('example')
  const isDir = res.isDirectory()
  console.log(
    'example exists: %s, is dir: %s', !!res, isDir,
  )
  const res2 = await exists('hello')
  console.log('hello exists: %s', res2)
})()
example exists: true, is dir: true
hello exists: null

Art Deco © Art Deco for Wrote 2019 Wrote Tech Nation Visa Tech Nation Visa Sucks

changelog

22 April 2019

1.0.5

  • [types] Cast the fs.Stats type for the makePromise result.

18 April 2019

1.0.4

  • [deps] Update and unlock dependencies.

2 April 2019

1.0.3

  • [doc] Fix footer.

1.0.2

  • [deps] Update makepromise.

24 January 2019

1.0.1

  • [doc] Fix footer image links to absolute.

1.0.0