@diotoborg/voluptatem-quod-magnam v2.9.99
Usage
you can use interface and type by importing Interface
and Type
.
const { Interface, Type } = require('@diotoborg/voluptatem-quod-magnam');
Interface:
const {
Interface: inter,
interfaceUtils
} = require('@diotoborg/voluptatem-quod-magnam'); // install the package
const ProfileInterface = {
Interface: true, // required and must be at first
name: 'string',
age: 'number',
gender: interfaceUtils.or('male', 'female'), // to use multi types
'job[?]': 'string' // not required
};
const myProfile = {
name: 'someone',
age: 99,
gender: 'male'
// job not required
};
const checkProfile = inter.check(ProfileInterface, myProfile);
console.log(checkProfile); // true
in this example we create interface called ProfileInterface
by adding Interface: true
in the object to make a interface which is required and must be at top or in first of interface-object.
key options
you can add options to key like the example above, by adding []
at the end of key and add inside it:
?
means the key not required, e.g:
const someInterface = {
'key': 'string', // require
'anotherKey[?]': '...' // not require
}
const someObject = {
'key': 'Hello World'
}
// no errors, 'anotherKey' not required.
!
means the key cannot be changed, e.g:
{
'key[!]': 'value'
}
// after use interface-check
someObject['key'] = 'new value';
console.log(someObject['key']); // value
also you can use both, e.g:
{
'key[?!]': 'value'
}
Type:
const { Type: type } = require('@diotoborg/voluptatem-quod-magnam');
const text = 'Hello World';
const getTextType = type.typeOf(text);
console.log(getTextType); // string
const { Type: type } = require('@diotoborg/voluptatem-quod-magnam');
const text = 'Hello World';
const number = 123;
const isTypeEqual = type.typeOfEqual(text, number);
console.log(isTypeEqual); // false
in above example we import type
at first then use function called typeOf
to get type of value which is a package called kind-of
for more information.
in second example we use function called typeOfEqual
to check if first-value type equal second-value type.
features & bugs
you can create a issue to share with us features and bugs on GitHub.
Contributing
1- fork the GitHub repository. 2- make your changes. 3- create pull request on GitHub. thanks ❤️ for your contributing.
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago