# simple-package-meta

> Easy access to information about the running package.

Latest version **0.0.3** (published 2022-08-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install simple-package-meta
pnpm add simple-package-meta
yarn add simple-package-meta
bun add simple-package-meta
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2022-08-24 |
| First published | 2022-08-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=12 |
| Dependencies | 3 |
| Unpacked size | 117.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Anadian |
| Maintainers | anad |
| Keywords | package, module, meta, data, json, name, version, free, libre, open, source, mit |

## Links

- npm: https://www.npmjs.com/package/simple-package-meta
- Repository: https://github.com/Anadian/simple-package-meta
- Homepage: https://github.com/Anadian/simple-package-meta#readme
- Issues: https://github.com/Anadian/simple-package-meta/issues
- npm.io page: https://npm.io/package/simple-package-meta

## Dependencies (3)

- [pkg-up](https://npm.io/package/pkg-up.md) ^4.0.0
- [env-paths](https://npm.io/package/env-paths.md) ^3.0.0
- [parse-json](https://npm.io/package/parse-json.md) ^6.0.2

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.0.3 (latest) — 2022-08-24
- 0.0.2 — 2022-08-24
- 0.0.1 — 2022-08-24

## README

# simple-package-meta
[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
[![Semantic Versioning 2.0.0](https://img.shields.io/badge/semver-2.0.0-brightgreen?style=flat-square)](https://semver.org/spec/v2.0.0.html)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=flat-square)](https://conventionalcommits.org)
[![License](https://img.shields.io/github/license/Anadian/simple-package-meta)](https://github.com/Anadian/simple-package-meta/blob/main/LICENSE)
[![ci](https://github.com/Anadian/simple-package-meta/actions/workflows/ci.yml/badge.svg)](https://github.com/Anadian/simple-package-meta/actions/workflows/ci.yml)
[![Coverage Status](https://coveralls.io/repos/github/Anadian/simple-package-meta/badge.svg?branch=main)](https://coveralls.io/github/Anadian/simple-package-meta?branch=main)
[![npm](https://img.shields.io/npm/v/simple-package-meta)](https://www.npmjs.com/package/simple-package-meta)

> Easy access to information about the running package.
# Table of Contents
- [Background](#Background)
- [Install](#Install)
- [Usage](#Usage)
- [API](#API)
- [Contributing](#Contributing)
- [License](#License)
# Background
A simple sort of convenience, sort of learning ECMAscript module package which takes a URL or an object like from `import.meta` and returns an object with information about the file like its name, version, directories and the nearest `package.json`.
# Install
Using [pnpm](https://pnpm.io/cli/add):
```sh
pnpm add --save simple-package-meta
```
It can, of course, also be installed by [NPM](https://docs.npmjs.com/cli/v8/commands/npm-install) or [Yarn](https://yarnpkg.com/getting-started/usage) using the normal methods.
# Usage
```js
import getPackageMeta from 'simple-package-meta'; //The default is just the getPackageMeta function
import * as PackageMetaNS from 'simple-package-meta'; //The whole namespace

var meta_info = getPackageMeta( import.meta ); //Same as PackageMetaNS.getPackageMeta
```
# API
The package comprises a single constructor and two functions.
```js
new PackageMeta( object ); //Can take either a URL string, a URL object or an `import.meta`-like object
```
This creates a new PackageMeta object albeit lacking some information which requires blocking operations; this is made available by importing the entire module namespace with the name `PackageMetaNS.PackageMeta()` and is intended mainly just for debugging or extending the object as generally you're better off using one of the following helper functions.
```js
getPackageMeta( object )
```
The default export, this asynchronously returns a complete PackageMeta object of the structure:
```js
{
	name: '',
	version: '',
	packageJSON: {},
	url: '',
	filename: '',
	dirname: '',
	paths: {
		packageDirectory: '',
		data: '',
		config: '',
		cache: '',
		log: '',
		temp: ''
	}
}
```
```js
PackageMetaNS.getPackageMetaSync( object )
```
Same as above except synchronous.
# Contributing
Changes are tracked in [CHANGELOG.md](CHANGELOG.md).
# License
MIT ©2022 Anadian

SEE LICENSE IN [LICENSE](LICENSE)

[![Creative Commons License](https://i.creativecommons.org/l/by-sa/4.0/88x31.png)](http://creativecommons.org/licenses/by-sa/4.0/)This project's documentation is licensed under a [Creative Commons Attribution-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/).

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