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 🙏

© 2024 – Pkg Stats / Ryan Hefner

copying

v1.0.1

Published

A shallow copy tool that makes you make decisions

Downloads

10

Readme

copying

copying is a library for making shallow copies. It requires you to make particular decisions about how you want properties to be copied from one object to another, to avoid ambiguity about what's actually happening in the copy.

This module exists to allow developers to make quick, deliberate decisions about how properties ought to be copied between objects, without compromising any clarity about what's actually going on.

Usage

This module's exports is a function that takes in a mandatory options object with the following properties, and returns a copier function.

  • enumerator: Must be one of the following string values:
    • "enumerable": The properties to copy will be iterated over using for .. in.
    • "ownKeys": The properties to copy will be retrieved using Reflect.ownKeys.
    • "keys": The properties to copy will be retrieved using Object.keys.
  • chain: Boolean. If true, the prototype chain will also be iterated over, and prototype properties will be copied to destination objects (not to the destination prototypes). If false, the prototype chain will not be used.
  • descriptor: Boolean. If true, properties will be copied by property descriptor. If false, properties will be copied by their resolved values.

Note: for .. in and Object.keys differ only in whether they include items in the prototype chain. Since we're deliberately choosing whether to iterate over the prototype chain, enumerable and keys are equivalent values for enumerator. Both are kept here, and implemented behind the scenes using the two different methods, in case there are performance differences between the two.

The returned copier function takes in objects similar to the way Object.assign works. The first argument is the destination object to be copied to, and the remaining arguments are source objects to be copied from, in the order they appear.

Examples

TODO (For now, take a look at the tests.)

License

MIT License. See LICENSE.txt