1.0.9 • Published 1 year ago

js-easy-typed v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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?')
1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago