Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@marcopeg/utils

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@marcopeg/utils

Javascript utils for server and client projects

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
624
decreased by-24.55%
Maintainers
1
Weekly downloads
 
Created
Source

utils

Javascript utils for server and client projects

cancelEvent

const cancelEvent = require('@marcopeg/utils/lib/cancel-event)

// use it as simple function with an event as argument
const onClick = (evt) => {
    cancelEvent(evt)
    ...
    my handler code
}

// @TODO: use it as middleware
const onClick = cancelEvent((evt) => {
    ... my handler
})

config

const config = require('@marcopeg/utils/lib/config)

// will trigger an error if the env variable is not defined
const serverPort = config.get('SERVER_PORT')

// will return a default vailue if the env variable is not defined
const appName = config.get('APP_NAME', 'Default App Name')

// (process.env.NODE_ENV === 'development')
if (config.isDev()) {
    ...
}

getErrorOrigin

Improve errors stack trace

pause

const pause = require('@marcopeg/utils/lib/pause)

async function foo () {
    console.log('before')
    await pause(2000) // stop process for 2s
    console.log('after')
}

truncate

const truncate = require('@marcopeg/utils/lib/truncate)

truncate('123456789', 5, '...')
-> 1...9

FAQs

Package last updated on 05 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc