New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@hydre/commons

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hydre/commons

You need some milk ?

  • 1.0.22
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

@hydre/commons

Javascript commons

Install

npm i @hydre/commons

Use:

Deferred Promise

Execute a promise outside scope

import { Deferred } from '@hydre/commons'

const def = new Deferred()
def.promise.then(console.log('slt'))

setTimeout(() => {
	def.resolve() // or deferred.reject()
}, 1000)

Decorators

@cache

Call the function/getter only once and keep the result in memory

import { cache } from '@hydre/commons'

class Foo {

	@cache
	bar() {
		console.log('This line will be printed only once')
		return new myApiCall()
	}

	@cache
	get baz() {
		return 5 + 5
	}
}

Helpers

mixin

Multiple class inheritance see exploring-es7-decorators

import { mixin } from '@hydre/commons'

const TimeStone = mixin({
	get canRewind() {
		return true
	}
})

const PlaysFortnite = mixin({
	isDumb() {
		return true
	}
})

@TimeStone
@PlaysFortnite
class Thanos {
	isDumb() {
		return false
	}
}

new Thanos().isDumb() |> console.log // print true

Keywords

FAQs

Package last updated on 15 Feb 2020

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