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

log-object

v1.1.0

Published

Log Objects with template string literals without repeating object name.

Downloads

15

Readme

Log Objects with template literal syntax

install

    npm install log-object

USAGE

const {Log} = require("log-object");

const myobj = {
  name: "John",
  surname: "Doe",
};

Log.obj(myobj, "Hello my name is ${name} and my surname is ${surname}");

// Or new raw syntax ( much more easier with like python f string syntax )

Log.raw(myobj, "Hello my name is {name} and my surname is {surname}");

which outputs =>

    Hello my name is John and surname is Doe

Methots

| Methot | Syntax | | --------- | ------------------------------------------ | | obj | Log.obj(myobj , ${name}) | | raw | Log.raw(myobj, {name}) | | error | throw Log.error(my_error_obj, ${name} | | error_raw | throw Log.error_raw(my_error_obj, {name} |

Parameters

| Parameter | Type | | --------- | ------ | | First | object | | Second | string |

Syntax

In template strings =>

console.log(
  `Hello my name is ${myobj.name} and my surname is ${myobj.surname}`
);

With Log Object Support =>

// Normal log

/* Syntax 1 = With Dollar Sign */

Log.obj(myobj, "Hello my name is ${name} and surname is ${surname}");

/* Syntax 2 = Without Dollar sign */

Log.raw(myobj, "Hello my name is {name} and surname is {surname}");

New Feature = Throw Log.error()

  • You can use same syntax for throw errors

let myPromise = new Promise((resolve, reject) => {
  if (/* condition */) {
    reject(Log.error(object, string))
  } else {
    resolve(Log.obj(another_object, another_string))
  }
})

or

try {
  fetch("my/path/to/json")
} catch (err) => {

  console.log(err)

  throw Log.error_raw(myobj, string)
}

Thats it.

Will Come in future

  • More methots with array and other types support

  • Better syntax

  • VS code auto completion extension

Changelog

  • 1.0.9

    • Added new option : raw log

    • You can throw errors with Log.error(object , string) or Log.error_raw(object, string)

  • 1.0.8

    • Fixed logs
  • 1.0.6

    • Fixed main javascript file error
  • 1.0.5

    • Added descriptions to types.
  • 1.0.4

    • Added Types
  • 1.0.2

    • Fixed not importing issues
  • 1.0.1

    • Added README
  • 1.0.0

    • Published