Extract sting utility to an external function

This commit is contained in:
Fawad Mirzad
2021-02-13 18:58:41 +01:00
parent 3ccc59c5ce
commit 62595c2421
2 changed files with 9 additions and 8 deletions

View File

@@ -1,8 +1,5 @@
import WatchPrimitiveProperties from '../utils/WatchPrimitiveProperties' import WatchPrimitiveProperties from '../utils/WatchPrimitiveProperties'
import {Str} from "./string";
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1)
}
export function getPropsValues(vueInst, props) { export function getPropsValues(vueInst, props) {
return Object.keys(props).reduce((acc, prop) => { return Object.keys(props).reduce((acc, prop) => {
@@ -26,8 +23,8 @@ export function bindProps(vueInst, googleMapsInst, props) {
if (noBind) continue if (noBind) continue
const setMethodName = 'set' + capitalizeFirstLetter(attribute) const setMethodName = 'set' + Str.capitalizeFirstLetter(attribute)
const getMethodName = 'get' + capitalizeFirstLetter(attribute) const getMethodName = 'get' + Str.capitalizeFirstLetter(attribute)
const eventName = attribute.toLowerCase() + '_changed' const eventName = attribute.toLowerCase() + '_changed'
const initialValue = vueInst[attribute] const initialValue = vueInst[attribute]
@@ -42,8 +39,7 @@ export function bindProps(vueInst, googleMapsInst, props) {
// although this may really be the user's responsibility // although this may really be the user's responsibility
if (type !== Object || !trackProperties) { if (type !== Object || !trackProperties) {
// Track the object deeply // Track the object deeply
vueInst.$watch( vueInst.$watch(attribute,
attribute,
() => { () => {
const attributeValue = vueInst[attribute] const attributeValue = vueInst[attribute]

5
src/utils/string.js Normal file
View File

@@ -0,0 +1,5 @@
export class Str {
static capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1)
}
}