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

js-easy-typed

v1.0.9

Published

Try typed js

Downloads

11

Readme

npm i js-easy-typed

Add typed in js, import index file

How install type, install as global

	install({
		$userName
		, $legajo
	})

Create primitive (string-number): new type, create

	const $userName = create(Joi.string().alphanum().min(3).max(20))
	const $legajo = create(Joi.number().min(1))

How update primitive

	const folder = $legajo(9)
	// update by set
	folder.set(2)
	// or 
	folder.value = 3

Primitives (number or string) work normally

	console.log( folder + 20 )

Create object: new type, create

	const $user = create({
		name: $userName,
		email: Joi.string().email(),
		password: Joi.string().min(6).max(20)
	})

Create function or class: new type

Validation call, define params as paramName=($typename)

	const updateName = typed(function updateName(name = ($userName), age = ($legajo)) {
			console.log(name , legajo)
		}
	)
	console.log( updateName('Daniel' , 30) )

Validation instance and update

	const classPerson = typed(class {
		constructor(name = ($userName)) {
			this.name = name
		}
		updateName(name = ($userName), age = ($legajo)) {
			this.name = name
			this.age = age
			console.log(this.name)
		}
	})

	let newObjectPerson = new classPerson('daniel')

Try using invalid parameters

	newObjectPerson.updateName('daniel2', 12)

How use typed? instance

	const learfen = $userName('learfen')
	console.log(learfen)
	console.log(learfen + ' test string as primitive, ready concat?')