just-do: Just do one thing.

450 阅读1分钟

Commit Type Emoji
Initial Commit 🎉 :tada:
Structure 🎨 :art:
Documentation 📝 :memo:
New Idea 💡 :bulb:
New Feature :sparkles:
Bug 🐛 :bug:
Version Tag 🔖 :bookmark:
Performance 🐎 :racehorse:
Tooling 🔧 :wrench:
Tests 🚨 :rotating_light:
Deprecation 💩 :poop:
Work In Progress (WIP) 🚧 :construction:
Upgrading ⬆️ :arrow_up:

Example:

"🎉 Initial Commit"

just-type

type checking.

import type from 'just-type';

function hello() {
    console.log('hello type');
}

type(); // undefined
type(undefined); // undefined
type(null); // null
type(''); // string
type('hello'); // string
type(0); // number
type(true); // boolean
type({}); // object
type([]); // array
type(hello); // function
type(/\./); // regexp

just-camelize

transform strings to camel case.

import camelize from 'just-camelize';

camelize('_hello_world'); // HelloWorld
camelize('_hello-world'); // HelloWorld
camelize('-hello_world'); // HelloWorld
camelize('-hello-world'); // HelloWorld

just-extend-it

objects extend.

import extend from 'just-extend-it';

let source = {
    just: 'just',
};

extend(source); // { just: 'just', }

extend(source, {
    hello: 'hello',
}); // { just: 'just', hello: 'hello', }

extend(source, {
    hello: 'hello',
}, {
    world: 'world',
}); // { just: 'just', hello: 'hello', world: 'world', }

extend(true, source, {
    hello: 'hello',
}); // { just: 'just', hello: 'hello', }

extend(true, source, {
    hello: {
        world: 'world',
    },
}); // { just: 'just', hello: { world: 'world', }, }

extend(true, source, {
    hello: {
        world: 'world',
    }, {
        hello: {
            hi: 'hi',
        },
    },
});// { just: 'just', hello: { world: 'world', hi: 'hi', }, }

extend(source, {
    hello: {
        world: 'world',
    },
}, {
    hello: {
        hi: 'hi',
    },
}); // { just: 'just', hello: { hi: 'hi', }, }

just-find

find key or value in object.

import find from 'just-find';

let object = {
    hello: 'hello',
    onClick: 'onClick',
    onTouch: 'onTouch',
    just: null,
    a: 0,
    b: 5,
    c: 7,
    d: 6,
    e: 8,
};

find(object, function (key, value) {
    return key === 'hello';
}); // { hello: 'hello', }

find(object, function (key, value) {
    return typeof value === 'number';
}); // { a: 0, b: 5, c: 7, d: 6, e: 8, }

find(object, function (key, value) {
    return key.slice(0, 2) === 'on';
}); // { onClick: 'onClick', onTouch: 'onTouch', }

find(object, function (key, value) {
    return value > 0 && value < 8;
}); // { b: 5, c: 7, d: 6, }

just-map-it

map object.

import map from 'just-map-it';

let object = {
    a: 0,
    b: 5,
    c: 7,
    d: 6,
    e: 8,
};

map(object, function (key, value) {
    return value * value;
}); // { a: 0, b: 25, c: 49, d: 36, e: 64, }

just-get-query

get url query.

import getQuery from 'just-get-query';

let search = location.search; // https://just-do.io?hello=hello&world=world

// null
getQuery('hello')
getQuery('hello', '')
getQuery('just', search)
getQuery('just', '?' + search)
getQuery('just', '??' + search)

// hello
getQuery('hello', search)
getQuery('hello', '?' + search)
getQuery('hello', '??' + search)

// world
getQuery('world', search)
getQuery('world', '?' + search)
getQuery('world', '??' + search)