1.0.0 • Published 7 years ago

starke v1.0.0

Weekly downloads
2
License
Apache License 2....
Repository
github
Last release
7 years ago

starke

starke means powerful

wonderful utils for javascript developer

模块简介

名称备注
CircularFormat环形对象格式化
Schedule定时任务的载体
ScheduleQueue按顺序执行定时任务的队列
StarkeLogger在控制台打印多彩的日志
DeterminationUtil 算法

Example of Determination

1. isEmpty Function

// isEmpty support strict or loose non-empty judgment of objects
// It can effectively avoid the null pointer problem in front-end development.
const obj = {
    name: '',
    auhtor: '',
    hobby: []
}
// false
const empty = isEmpty(obj)
// ture
const empty = isEmpty(obj, true)

2. clearObject Function

// Sometimes we want to keep the keys of the object while emptying the cache
let cache = {
    name: 'starke',
    auhtor: '4everlynn',
    hobby: ['coding', 'music']
}
// after call this obj will be empty
// like {name: '', author: '', hobby: []} 
// which could be judged as true by isEmpty
clearObject(obj)

3. equals Function

// Sometimes we want to determine whether two objects are equal in attribute values.
// this function will be usefull
let user = {
    name: '4everlynn',
    hobby: ['coding', 'music']
}
let cache = {
    name: '4everlynn',
    hobby: ['coding', 'music']
}
// false
const isEqual = user === cache
// true
const starkeEq = equals(user, cache)
// It can even handle the equality of ring objects.
// And starke create this function by hash, which is very stable

4. hash Function

// Get the hash code of the string
const string = 'Hello Starke'
const code = hash(string)

5. filter Function

// Filter array by condition
const users = [{
    user: '4everlynn',
    age: 20
}, {
    user: 'Starke',
    age: 1
}, {
    user: 'Lynn',
    age: 18
}]
/** result 
 [{
    user: '4everlynn',
    age: 20
}, {
    user: 'Lynn',
    age: 18
}]
 */
const target = filter(users, item => {
    return item.age < 20
})

6. group Function

// group array by condition
const users = [{
    user: '4everlynn',
    age: 20,
    role: 'admin'
}, {
    user: 'Starke',
    age: 1,
    role: 'admin'
}, {
    user: 'Lynn',
    age: 18,
    role: 'user'
}]
// result:
// [ [ { user: '4everlynn', age: 20, role: 'admin' },
//         { user: 'Starke', age: 1, role: 'admin' } ],
//       [ { user: 'Lynn', age: 18, role: 'user' } ] ]
const target = group(users, item => {
    // group by 'role'
    return item.role
})

7. hashColor Function

const category = 'Operate'
// Generate a stable RGB color based on the string
// rgb(232.2421875, 160, 244)
const color = hashColor(category)
// No matter how many times it runs, the result is the same.
1.0.75

5 years ago

1.0.74

5 years ago

1.0.73

6 years ago

1.0.72

6 years ago

1.0.71

6 years ago

1.0.69

6 years ago

1.0.70

6 years ago

1.0.68

6 years ago

1.0.66

6 years ago

1.0.65

6 years ago

1.0.67

6 years ago

1.0.64

6 years ago

1.0.62

6 years ago

1.0.61

6 years ago

1.0.63

6 years ago

1.0.60

6 years ago

1.0.59

6 years ago

1.0.58

6 years ago

1.0.57

6 years ago

1.0.56

6 years ago

1.0.55

6 years ago

1.0.54

6 years ago

1.0.53

6 years ago

1.0.52

6 years ago

1.0.51

6 years ago

1.0.49

7 years ago

1.0.48

7 years ago

1.0.47

7 years ago

1.0.46

7 years ago

1.0.45

7 years ago

1.0.43

7 years ago

1.0.42

7 years ago

1.0.41

7 years ago

1.0.40

7 years ago

1.0.39

7 years ago

1.0.38

7 years ago

1.0.37

7 years ago

1.0.36

7 years ago

1.0.35

7 years ago

1.0.34

7 years ago

1.0.33

7 years ago

1.0.32

7 years ago

1.0.31

7 years ago

1.0.30

7 years ago

1.0.29

7 years ago

1.0.28

7 years ago

1.0.27

7 years ago

1.0.26

7 years ago

1.0.25

7 years ago

1.0.24

7 years ago

1.0.23

7 years ago

1.0.22

7 years ago

1.0.21

7 years ago

1.0.20

7 years ago

1.0.19

7 years ago

1.0.18

7 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago