7.2.0 • Published 1 year ago

locate-path v7.2.0

Weekly downloads
50,548,694
License
MIT
Repository
github
Last release
1 year ago

locate-path

Get the first path that exists on disk of multiple paths

Install

$ npm install locate-path

Usage

Here we find the first file that exists on disk, in array order.

import {locatePath} from 'locate-path';

const files = [
	'unicorn.png',
	'rainbow.png', // Only this one actually exists on disk
	'pony.png'
];

console(await locatePath(files));
//=> 'rainbow'

API

locatePath(paths, options?)

Returns a Promise<string> for the first path that exists or undefined if none exists.

paths

Type: Iterable<string>

The paths to check.

options

Type: object

concurrency

Type: number\ Default: Infinity\ Minimum: 1

The number of concurrently pending promises.

preserveOrder

Type: boolean\ Default: true

Preserve paths order when searching.

Disable this to improve performance if you don't care about the order.

cwd

Type: URL | string\ Default: process.cwd()

The current working directory.

type

Type: string\ Default: 'file'\ Values: 'file' | 'directory'

The type of paths that can match.

allowSymlinks

Type: boolean\ Default: true

Allow symbolic links to match if they point to the chosen path type.

locatePathSync(paths, options?)

Returns the first path that exists or undefined if none exists.

paths

Type: Iterable<string>

The paths to check.

options

Type: object

cwd

Same as above.

type

Same as above.

allowSymlinks

Same as above.

Related


find-upweb-desktop-helperfree-minarchetype-librarycomponennentteasy-select-rnchinjowwchinjowvuedragdropuploadimagespopsmart-common-authreact-native-bluetooth2killi8n-react-native-fast-imagepipihomern-send-smsspecify-importsbabel-specify-imports@icanpm/api-master@arisageha/react-lazyload@arisageha/react-lazyload-fixfoshata-markdown@cashremit/cr-streamline-icons@almeidaa/msreact-native-template-rfbaseairscanairscan-examplebb-chatreact-native-esc-pos-sahaab@borisovart/atol-kkt-module@frxf/frxfkubii-apideneme323112@texttree/demo-bsa-reference-rcl@fundefund/funde_ck@ntt_app/react-native-custom-notificationreact-native-custom-text-hwjames@sonammalhotra/lotide@smishra17/lotide@cheapthrills/lotidereact-native-covid-sdkgql_din_modbitgetalex-frontend-sdk-stagingafryxiconsreact-native-thanh-toast-librarymutasi-bcasalut_gongjang_first_module@jttechnic/interpreter@thanhnguyen14797/react-native-thanh-toast-library@l1nyanm1ng/react-picture-viewer@saeon/quick-formcthpb-plugin-social@iobroker-community-adapters/iobroker.device-watcher@olivervorasai/slidermysql-formatreact-native-printer-brothersrn-pdf-reader-offlinecbmis-ai-toolbox@newhorizon-tech/dd-npm-package-templatereact-native-shekhar-bridge-testcogoportutilsukor-remasteruncoded-connectlevibestliblevibestlib2levilibtest19levilibtest24levilibtest25levilibtest26levilibtest27levilibtest28levilibtest29levinodelib@nicholasjj/lotidetemp-mail-fuckwilscanner@khalitovadel/abstract-repository@oiti/documentoscopy-react-nativejs4cytoscape@respondea/cordova-plugin-v-inappbrowser@mink-opn/build-tokensquoc-testreact-native-slider-kfnodejs-fileshareunblock-block-save-variables@infinitebrahmanuniverse/nolb-locat@prodam/prodam-typescclibyarntest@saaspe/componentshyperpass-sdkplginexpand-react-bridgeopea-bootstraapnetlify-cliluminos-ui-coresklif-ui-kitsklif-apits-handy@everything-registry/sub-chunk-2093iqra-calculatorjawwy-sdk
7.2.0

1 year ago

7.1.1

2 years ago

7.1.0

2 years ago

7.0.0

3 years ago

6.0.0

4 years ago

5.0.0

5 years ago

4.0.0

5 years ago

3.0.0

6 years ago

2.0.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago