npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

update-pkg-extended

v4.0.4

Published

Update package.json with ease

Downloads

116

Readme

update-pkg-extended

Update package.json with ease

license JavaScript Style Guide

NPM version NPM downloads

Install

npm install --save update-pkg-extended

or

yarn add update-pkg-extended

Usage

const Pkg = require("update-pkg-extended");

const pkg = new Pkg();
pkg.data; //=> package.json object

// Update package.json fields
pkg.set("author.name", "panz3r");

// Get version
pkg.version.get(); // => '0.0.9'

// Update minor version
pkg.version.newMinor(); // => '0.1.0'

// Save synchronously
pkg.saveSync();
// or using Promise
pkg.save().then(/* ... */);

API

new Pkg([cwd, options])

Return a new Pkg instance representing package.json located at cwd folder.

cwd

Type: string Default: './'

Directory where a package.json can be found. Defaults to current directory.

options

create

Type: boolean Default: false

Create package.json when it does not exist.

.data

Type: object Default: {}

The parsed content of package.json.

.set(keyPath, value)

Set value by the given keyPath like author.name and value like panz3r.

.get(keyPath [,defaultValue])

Get value by the given keyPath. If keyPath is not found and defaultValue is specified, defaultValue will be returned, otherwise will return undefined

.update(keyPath, updateFn)

Update keyPath value using updateFn function. updateFn is invoked with the current keyPath value.

.append(keyPath, value)

Append value to the given keyPath.

.prepend(keyPath, value)

Prepend value to the given keyPath.

.version

Type: Version

Manage version field in a semver-compatible way

.get([segment])

Return formatted version (0.0.3) if segment is not specified, otherwise returns the required segment

segment

Type: string Default: undefined

Specify required version segment, should be one of major, minor, patch or prerelease

.newMajor()

Increment major version and reset all others fields

pkg.version.get(); // => '0.0.3'

// New major version
pkg.version.newMajor(); // => '1.0.0'
.newMinor()

Increment minor version and reset patch field

pkg.version.get(); // => '0.0.3'

// New minor version
pkg.version.newMinor(); // => '0.1.0'
.major([major])

Increment or set major

pkg.version.get(); // => '0.0.3'

// Increment major version
pkg.version.major(); // => '1.0.3'

// Set major version to specified value
pkg.version.major(3); // => '3.0.3'
.minor([minor])

Increment or set minor version

pkg.version.get(); // => '0.0.3'

// Increment minor version
pkg.version.minor(); // => '0.1.3'

// Set minor version to specified value
pkg.version.minor(3); // => '0.3.3'
.patch([patch])

Increment or set patch version

pkg.version.get(); // => '0.0.3'

// Increment minor version
pkg.version.patch(); // => '0.0.4'

// Set minor version to specified value
pkg.version.patch(9); // => '0.0.9'
.prerelease(prereleaseIdentifier, [prereleaseVersion])

Increment or set prerelease version

pkg.version.get(); // => '0.0.3'

// Set prerelease version to specified value
pkg.version.prerelease("beta", 9); // => '0.0.3-beta.9'

// Increment prerelease version
pkg.version.prerelease("beta"); // => '0.0.4-beta.0'

// Increment prerelease version
pkg.version.prerelease("beta"); // => '0.0.4-beta.1'

N.B: Bumping prerelease version when it is not set will also bump patch version

.save()

Type: function Return: Promise

Save data to package.json.

.saveSync()

Type: function Return: this

Save data to package.json synchronously.

Credits


Made with :sparkles: & :heart: by Mattia Panzeri and contributors