@mnrendra/use-package
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@mnrendra/use-package

A utility to provide package.json data. Because @mnrendra/read-package is expensive, this utility is used to save it.

Install

npm i @mnrendra/use-package

Usage

Using CommonJS:

index.js

const { clonePackage } = require('@mnrendra/use-package')
const submodule = require('./submodule')

const main = async () => {
  await clonePackage()
  submodule()
}

submodule.js

const { pack } = require('@mnrendra/use-package')

const main = () => {
  pack.customField = 'customField'

  console.log(pack.name) // Will print your package.json name.
  console.log(pack.version) // Will print your package.json version.
  console.log(pack.customField) // Will print your package.json customField.
}

Using ES Module:

index.js

import { clonePackage } from '@mnrendra/use-package'
import submodule from './submodule'

const main = async () => {
  await clonePackage()
  submodule()
}

submodule.js

import { pack } from '@mnrendra/use-package'

const main = () => {
  pack.customField = 'customField'

  console.log(pack.name) // Will print your package.json name.
  console.log(pack.version) // Will print your package.json version.
  console.log(pack.customField) // Will print your package.json customField.
}

Types

import type {
  Package // @mnrendra/types-package
} from '@mnrendra/use-package'

License

MIT

Author

@mnrendra

Package Sidebar

Install

npm i @mnrendra/use-package

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

6.54 kB

Total Files

9

Last publish

Collaborators

  • mnrendra