# sb-resolve

> require.resolve algorithm implemented with awesome features

Latest version **3.0.4** (published 2016-07-27) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install sb-resolve
pnpm add sb-resolve
yarn add sb-resolve
bun add sb-resolve
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 3.0.4 |
| Published | 2016-07-27 |
| First published | 2016-04-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | steelbrain |
| Maintainers | steelbrain |
| Keywords | require, node, algorithm |

## Links

- npm: https://www.npmjs.com/package/sb-resolve
- Repository: https://github.com/steelbrain/resolve
- Homepage: https://github.com/steelbrain/resolve#readme
- Issues: https://github.com/steelbrain/resolve/issues
- npm.io page: https://npm.io/package/sb-resolve

## Dependencies (1)

- [sb-promisify](https://npm.io/package/sb-promisify.md) ^1.3.0

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 3.0.4 (latest) — 2016-07-27
- 3.0.3 — 2016-07-23
- 3.0.2 — 2016-07-23
- 3.0.1 — 2016-07-14
- 3.0.0 — 2016-07-13
- 2.0.1 — 2016-07-09
- 2.0.0 — 2016-06-03
- 1.1.0 — 2016-04-15
- 1.0.2 — 2016-04-11
- 1.0.1 — 2016-04-11
- 1.0.0 — 2016-04-03

## README

# Resolve

`sb-resolve` is a node module that supports `require.resolve`'s lookup algorithm but with advance configurations.

## Installation

```
npm install --save sb-resolve
```

## API

```js
type $Options = {
  fs?: {
    stat?: ((filePath: string) => Promise<FS.Stats>),
    readFile?: ((filePath: string) => Promise<string>)
  },
  root?: string,
  process?: ((manifest: Object) => string),
  extensions?: Array<string>,
  moduleDirectories?: Array<string>
} = {
  fs: {
    stat: promisify(FS.stat),
    readFile: promisify(FS.readFile),
  },
  root: path.resolve('./'),
  process: manifest => manifest.main || './index'
  extensions: ['.js', '.json'],
  moduleDirectories: ['node_modules']
}

function isLocal(request: string): boolean
function isCore(request: string): boolean
function resolve(request: string, requestFile: string, options: $Options): Promise<string>

export { isLocal, isCore, resolve }
```

## Examples

```js
// /tmp/test/lib/index.js
import { resolve, isCore } from 'sb-resolve'

console.log(isCore('fs')) // true
console.log(isCore('babel')) // false

resolve('babel', __filename, {
  root: Path.join(__dirname, '..'),
}).then(function(mainFile) {
  console.log(mainFile) // /tmp/test/node_modules/babel/index.js
})
```

## Notes

To give developers full control over the resolution, this module does not keep looking for `moduleDirectories` upwards, to add those directories, you must manually add those `node_modules` directories' absolute paths to `moduleDirectories` or add their parent folders in `root`

## License
This project is licensed under the terms of MIT License. See the LICENSE file for more info.

---
_Source: https://npm.io/package/sb-resolve · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
