1.0.0 • Published 5 months ago

@mnrendra/use-package v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@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