mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-10 17:33:24 +01:00
Chance camelize to capitalize the first letter
This commit is contained in:
parent
643f91c18b
commit
6a6eb8fa63
@ -32,7 +32,7 @@ class FeatureModel {
|
|||||||
this._attributes = {};
|
this._attributes = {};
|
||||||
|
|
||||||
// Create type method ...
|
// Create type method ...
|
||||||
this[`is${FeatureModel.camelize(type)}Model`] = () => true;
|
this[`is${FeatureModel.capitalize(type)}Model`] = () => true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
@ -40,17 +40,18 @@ class FeatureModel {
|
|||||||
return { ...this._attributes };
|
return { ...this._attributes };
|
||||||
}
|
}
|
||||||
|
|
||||||
static camelize(str) {
|
static capitalize(str) {
|
||||||
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) => (index === 0 ? word.toLowerCase() : word.toUpperCase())).replace(/\s+/g, '');
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
setAttributes(attributes) {
|
setAttributes(attributes) {
|
||||||
for (const attr in attributes) {
|
|
||||||
const funName = `set${FeatureModel.camelize(attr)}`;
|
Object.keys(attributes).forEach((attr) => {
|
||||||
|
const funName = `set${FeatureModel.capitalize(attr)}`;
|
||||||
const value = attributes[attr];
|
const value = attributes[attr];
|
||||||
this[funName](value);
|
this[funName](value);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
|
Loading…
Reference in New Issue
Block a user