Code Monkey home page Code Monkey logo

just-do's Introduction

Just - Just do one thing.

Packages

Usage

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

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

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', }, }

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, }

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, }

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)

just-ajax

ajax request.

import ajax from 'just-ajax';

ajax({
    url: 'http://api.hello.com/',
    type: 'POST',
    data: {
        username: 'hello',
        password: 'world',
    },
    success: function (response) {
        console.log(response);
    },
    error: function (error) {
        console.log(error);
    },
});

just-do's People

Contributors

dabanlee avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

ducban

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.