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

@lowdefy/helpers

v4.4.0

Published

Lowdefy helper functions

Downloads

11,507

Readme

@lowdefy/helpers

Lowdefy helper functions

Usage

applyArrayIndices

(arrayIndices: number[], name: string): string

Apply arrayIndices to a object id. Substitutes all instances of $ character in name with a index from arrayIndices, until there are no more indices or $'s.

applyArrayIndices([1, 2], 'array.$.subArr.$'); // returns 'array.1.subArr.2'

get

(
  target: any,
  path: string | number,
  options?: {
    default?: any,
  }
): any

Get a value from a target object, using path with dot-notation. Returns undefined or the optional default value if the value is not found.

get({ a: [{ b: 1 }] }, 'a.0.b'); // returns 1
get({ a: [{ b: 1 }] }, 'a.7.b', { default: 4 }); // returns 4

mergeObjects

(objects: objects[]): object

Merges an array of objects using lodash.merge

mergeObjects([
  { a: 1, c: 4 },
  { a: 2, b: 3 },
]); // returns { a: 2, b: 3, c: 4 }

omit

(object: object, list: string[]): object

Remove an array of keys from a object. Uses unset from this package.

omit({ a: 1, b: 2, c: 3, d: 4 }, ['a', 'd']); // returns { b: 2, c: 3 }

serializer

serializer.copy
serializer.deserialize
serializer.deserializeFromString
serializer.serialize
serializer.serializeToString

set

(
  target: any,
  path: string,
  value: any
): void

Sets a value in a object at a key given by path.

const obj = { a: 1 };
set(obj, 'b.c', 2);
// obj becomes { a: 1, b: { c: 2 } }

stableStringify

(
  object: any
  options?: {
    cmp?: function,
    cycles?: boolean,
    space?: string | number,
    replacer?: function
  }
)

Derived from https://github.com/substack/json-stable-stringify

Returns a deterministic JSON stringified object.

swap

(
  arr: any[],
  from: number,
  to: number
)

Swaps the object at the from index with the object at the to index.

swap([0, 1, 2, 3, 4], 2, 3); // returns [0, 1, 3, 2, 4]

type

unset

(object: object, property: 'string')

Unset a property on a object. Supports dot-notation.

const obj = { a: { b: [] } };
unset(obj, 'a.b'); //
// obj becomes { a: {} }

urlQuery

urlQuery.parse
(string: string): object

Parse a urlQuery serialized by urlQuery.stringify.

urlQuery.parse('a=%7B%22b%22%3A%221%22%7D'); // returns { a: { b: '1' } }
urlQuery.stringify
(object: object): string

Serialize a urlQuery object to use as URL query parameters. Nested objects are serialized using serializer.serializeToString.

urlQuery.stringify({ a: { b: '1' } }); // returns 'a=%7B%22b%22%3A%221%22%7D'

More Lowdefy resources

  • Getting started with Lowdefy - https://docs.lowdefy.com/tutorial-start
  • Lowdefy docs - https://docs.lowdefy.com
  • Lowdefy website - https://lowdefy.com
  • Community forum - https://github.com/lowdefy/lowdefy/discussions
  • Bug reports and feature requests - https://github.com/lowdefy/lowdefy/issues

Licence

Apache-2.0