-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
featureNew feature or requestNew feature or request
Description
A base class for any class to inherit from, filled with helpful getters, setters, and methods.
export default class Methods {
get empty() {}
get inspect() {}
get not() {}
get size() {}
get isEmail() {}
get isUrl() {}
get isSecureUrl() {}
get isDate() {}
get isHEX() {}
get isRGB() {}
get isRGBA() {}
get isHSL() {}
get isHSLA() {}
get isPhoneNumber() {}
get isNumber() {}
get isIP() {}
fromJSON() {}
toJSON() {}
fromClipboard() {}
toClipboard() {}
toCamelCase() {}
toSnakeCase() {}
toKababCase() {}
toHungarianCase() {}
toPascalCase() {}
toConstCase() {}
remapKeys(case = 'camelCase') {}
each(callback) {}
where(condition, callback) {}
remove(condition, callback) {}
re(regularExpression, callback) {}
sort(condition, callback) {}
}Each
Loop method to iterate over an array or object.
method.each( callback( [iteratee], [index] ) );
class Fruits extends Methods {
#locals = [];
get defaults() {
return this.#locals;
}
set defaults(globals = []) {
this.#locals = globals;
}
constructor(...fruits) {
this.defaults(fruits);
}
}
let bucketOfFruits = new Fruits('Tomato', 'Banana', 'Watermelon', 'Apple', 'Orange', 'Mangoe');
let inventoryOfFruits = new Fruits(
{ 'type': 'Apples', 'count': 59 },
{ 'type': 'Bananas', 'count': 34 },
{ 'type': 'Mangoes', 'count': 95 },
{ 'type': 'Oranges', 'count': 78 },
{ 'type': 'Tomatoes', 'count': 43 },
{ 'type': 'Watermelons', 'count': 20 }
);
bucketOfFruits.each((fruit) => {
console.log(fruit);
});
inventoryOfFruits.each(({count, type}) => {
console.log(`We have ${count} ${type}.`);
});Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
featureNew feature or requestNew feature or request