Skip to content

Commit

Permalink
releases 3.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Sep 25, 2021
1 parent 53d5767 commit 529cc7c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 39 deletions.
58 changes: 29 additions & 29 deletions func/cookie.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,33 @@ export interface CookieOptions {
expires?: string;
}

export interface XECookie {
/**
* Cookie 操作函数
*/
export declare function CookieFunc(): cookie;

/**
* Cookie 操作函数
* @param name 键/数组/对象
*/
export declare function CookieFunc(name: string): cookie;

/**
* Cookie 操作函数
* @param name 键/数组/对象
* @param value 值
*/
export declare function CookieFunc(name: string, value: any): cookie;

/**
* Cookie 操作函数
* @param name 键/数组/对象
* @param value 值
* @param options 可选参数
*/
export declare function CookieFunc(name: string, value: any, options: CookieOptions): cookie;

export type cookie = typeof CookieFunc & {
/**
* 根据 name 判断 Cookie 是否存在
* @param name 键
Expand All @@ -38,7 +64,7 @@ export interface XECookie {
* @param value 值
* @param options 可选参数
*/
set(name: string, value: any, options?: CookieOptions): this;
set(name: string, value: any, options?: CookieOptions): cookie;

/**
* 根据 name 获取 Cookie
Expand All @@ -64,35 +90,9 @@ export interface XECookie {
getJSON(): any;
}

/**
* Cookie 操作函数
*/
export declare function cookie(): XECookie;

/**
* Cookie 操作函数
* @param name 键/数组/对象
*/
export declare function cookie(name: string): XECookie;

/**
* Cookie 操作函数
* @param name 键/数组/对象
* @param value 值
*/
export declare function cookie(name: string, value: any): XECookie;

/**
* Cookie 操作函数
* @param name 键/数组/对象
* @param value 值
* @param options 可选参数
*/
export declare function cookie(name: string, value: any, options: CookieOptions): XECookie;

declare module './ctor' {
interface XEUtilsMethods {
cookie: typeof cookie;
cookie: cookie;
}
}

Expand Down
22 changes: 13 additions & 9 deletions func/cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,37 +110,41 @@ function cookie (name, value, options) {
return false
}

function hasCookieItem (key) {
return includes(cookieKeys(), key)
function hasCookieItem (value) {
return includes(cookieKeys(), value)
}

function getCookieItem (name, key) {
return cookie(name, key)
function getCookieItem (name) {
return cookie(name)
}

function setCookieItem (name, key, options) {
cookie(name, key, options)
function setCookieItem (name, value, options) {
cookie(name, value, options)
return cookie
}

function removeCookieItem (name, options) {
cookie(name, 0, assign({ expires: -1 }, setupDefaults.cookies, options))
cookie(name, '', assign({ expires: -1 }, setupDefaults.cookies, options))
}

function cookieKeys () {
return keys(cookie())
}

function cookieJson () {
return cookie()
}

assign(cookie, {
has: hasCookieItem,
set: setCookieItem,
setItem: setCookieItem,
get: getCookieItem,
getItem: cookie,
getItem: getCookieItem,
remove: removeCookieItem,
removeItem: removeCookieItem,
keys: cookieKeys,
getJSON: cookie
getJSON: cookieJson
})

module.exports = cookie
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xe-utils",
"version": "3.3.2",
"version": "3.3.3",
"description": "JavaScript 函数库、工具类",
"main": "index.js",
"unpkg": "dist/xe-utils.umd.min.js",
Expand Down

0 comments on commit 529cc7c

Please sign in to comment.