Skip to content

a easy use js library for all kinds of operates in js

License

Notifications You must be signed in to change notification settings

huiyan-fe/kits-js

This branch is 1 commit ahead of master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

bf2d552 · Feb 12, 2022

History

28 Commits
Jun 19, 2019
Jun 19, 2019
Jun 19, 2019
Dec 28, 2018
Jul 12, 2018
Jun 1, 2018
Jun 1, 2018
May 9, 2019
Jun 19, 2019
Jun 1, 2018
Dec 19, 2018
Feb 12, 2022
Jun 19, 2019
Jul 12, 2018
Jul 12, 2018
Feb 12, 2022

Repository files navigation

kits-js

a easy use js library for some operates with js  

1. http

1.1 http.fetch(option)

1.2 http.ajax(option)

1.3 http.jsonp(option)

option parameters:

param type description
url String The URL of the resource/api
timeout Number The URL of the resource/api
method String GET or POST method default GET
success Function the request success callback
fail Function the request fail callback

example:

    http.fetch({
        url: 'http://jsonplaceholder.typicode.com/users/1',
        method: 'GET',
        success: (rs) => {
        },
        fail: (rs) => {
        }
    });

1.4 http.download(url,fileName)

param type description
url String The URL of the resource/api
fileName String the name you want to name the file

2. obj

for Object operations

2.1. obj.deepClone(source)

source: 
    the Object you want to deep clone
return:
    an object the same as source
    let clone = obj.deepClone({name:'Daniel',age:44})

2.2. obj.diff(src1,src2)

src1/src2:     
    the object you want to get the diff of two objects   
return:   
    return the diff of src2 relative to src1   
    var o1 = {
        a: {
            aa: {
                aaa: 1
            },
            bb: {
                bbb: 2
            }
        },
        b: 'hello',
        e: 'o2 dont have',
        g: 'o2 different',
    }
    var o2 = {
        a: {
            aa: {
                aaa: 'first'
            },
            bb: {
                bbb: 2
            }
        },
        c: 'daniel',
        f: 'o1 dont have',
        g: 'different',
    }
    let diff = obj.diff(o1,o2);

2.3. obj.merge(src1,src2)

src1/src2:  
    the same as obj.diff  
return:  
    return the merged object of src1 && src2  
    the src2 will only overwrite the string/number property values of src1

example:

    let merged = obj.merge(o1,o2)

About

a easy use js library for all kinds of operates in js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published