elysius
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

elysius

✨ Features

  • ESM Support
  • Tree Shakeable
  • Supports async and sync functions

📦 Installation

pnpm install elysius

📚 Usage

import { find, findSync } from "elysius";

const path = await find("package.json"); // returns `null` if not found
const path = findSync("package.json"); // returns `null` if not found

const path = await find(["package.json", "tsconfig.json"]); // returns the first found file
const path = findSync(["package.json", "tsconfig.json"]); // returns the first found file

const path = await find(["package.json", "tsconfig.json"], {
  cwd: "src",
  async test: (path) => {
    const base = basename(file);
    if (base === "package.json") {
      const content = JSON.parse(await readFile(file, "utf-8"));
      return content.version;
    }
    return false;
  }
}); // returns `package.json` if it has a version field

const path = findSync(["package.json", "tsconfig.json"], {
  cwd: "src",
  test: (path) => {
    const base = basename(file);
    if (base === "package.json") {
      const content = JSON.parse(readFileSync(file, "utf-8"));
      return content.version;
    }
    return false;
  }
}); // returns `package.json` if it has a version field

📄 License

Published under MIT License.

Readme

Keywords

none

Package Sidebar

Install

npm i elysius

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

9.81 kB

Total Files

7

Last publish

Collaborators

  • luxass