Skip to content

Remove use of lodash #2

Open
Open
@airtonix

Description

@airtonix

Basically You're adding quite a lot of kilobytes to the lib by using lodash, uncompressed it can reach a 1mb.

https://github.com/vuedev-com/vue-localize/blob/master/src/vue-localize.js#L1

Add something like this to lib/utils.js, to replace lodash.get

export function get (obj, notation, defaultValue) {
    return notation.split('.')
        .reduce( (key) => obj[key], obj) || defaultValue;
}

Then replace :

replace(str, foo, bar) with : str.replace(foo, bar)
each(collection, (key, value) => foo(key, value) ) with :

    const helpers = { translate };
    Object.keys(helpers)
        .forEach( (name) => {
            Vue.filter(name, helpers[name]);
            Vue.prototype['$' + name] = helpers[name];
        });

you can use https://github.com/joakimbeng/kebab-case in place of lodash.kebabcase

The story is that through experience and pain, I've learnt to avoid using lodash, underscore, except when writing CLI tools or server side code

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions