From 4e41ad78489322e33da916198dbb7b9026c97c83 Mon Sep 17 00:00:00 2001 From: alan Date: Fri, 5 Jul 2019 10:13:26 +0800 Subject: [PATCH 1/3] feat: KERNEL-798 core/func/string --- typescript/core/func/string.ts | 13 +++++++++++++ typescript/index.ts | 9 +++++++++ 2 files changed, 22 insertions(+) create mode 100644 typescript/core/func/string.ts diff --git a/typescript/core/func/string.ts b/typescript/core/func/string.ts new file mode 100644 index 000000000..fae4d7d66 --- /dev/null +++ b/typescript/core/func/string.ts @@ -0,0 +1,13 @@ +export declare type _startWith = (str: string, startTag: string) => boolean; + +export declare type _endWith = (str: string, endTag: string) => boolean; + +export declare type _getQuery = (str: string, name: string) => string|null; + +export declare type _appendQuery = (str: string, paras: {[key: string]: string|number}) => string; + +export declare type _replaceAll = (str: string, s1: string, s2: string) => string; + +export declare type _perfectStart = (str: string, start: string) => string; + +export declare type _allIndexOf = (str: string, sub: string) => number[]; diff --git a/typescript/index.ts b/typescript/index.ts index 95723ce61..b3d9cae20 100644 --- a/typescript/index.ts +++ b/typescript/index.ts @@ -1,6 +1,7 @@ import { _addI18n, _i18nText } from "./core/i18n"; import { _OB } from "./core/ob"; import { _pushArray, _pushDistinct, _pushDistinctArray} from "./core/func/array"; +import {_startWith, _allIndexOf, _appendQuery, _endWith, _getQuery, _perfectStart, _replaceAll} from "./core/func/string"; export declare module BI { namespace i18n { @@ -13,4 +14,12 @@ export declare module BI { const pushArray: _pushArray; const pushDistinct: _pushDistinct; const pushDistinctArray: _pushDistinctArray; + + const startWith: _startWith; + const endWith: _endWith; + const allIndexOf: _allIndexOf; + const appendQuery: _appendQuery; + const getQuery: _getQuery; + const perfectStart: _perfectStart; + const replaceAll: _replaceAll; } From bf99ea40daf475b6c406933d8aa1ca2db40224b3 Mon Sep 17 00:00:00 2001 From: alan Date: Fri, 5 Jul 2019 10:23:12 +0800 Subject: [PATCH 2/3] =?UTF-8?q?docs:=20=E5=8A=A0=E5=85=A5=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- typescript/index.ts | 55 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/typescript/index.ts b/typescript/index.ts index b3d9cae20..4d17a6bb6 100644 --- a/typescript/index.ts +++ b/typescript/index.ts @@ -15,11 +15,60 @@ export declare module BI { const pushDistinct: _pushDistinct; const pushDistinctArray: _pushDistinctArray; + /** + * 判断字符串是否已指定的字符串开始 + * @param str source字符串 + * @param {String} startTag 指定的开始字符串 + * @return {Boolean} 如果字符串以指定字符串开始则返回true,否则返回false + */ const startWith: _startWith; + + /** + * 判断字符串是否以指定的字符串结束 + * @param str source字符串 + * @param {String} endTag 指定的字符串 + * @return {Boolean} 如果字符串以指定字符串结束则返回true,否则返回false + */ const endWith: _endWith; - const allIndexOf: _allIndexOf; - const appendQuery: _appendQuery; + + /** + * 获取url中指定名字的参数 + * @param str source字符串 + * @param {String} name 参数的名字 + * @return {String} 参数的值 + */ const getQuery: _getQuery; - const perfectStart: _perfectStart; + + /** + * 给url加上给定的参数 + * @param str source字符串 + * @param {Object} paras 参数对象,是一个键值对对象 + * @return {String} 添加了给定参数的url + */ + const appendQuery: _appendQuery; + + /** + * 将所有符合第一个字符串所表示的字符串替换成为第二个字符串 + * @param str source字符串 + * @param {String} s1 要替换的字符串的正则表达式 + * @param {String} s2 替换的结果字符串 + * @returns {String} 替换后的字符串 + */ const replaceAll: _replaceAll; + + /** + * 总是让字符串以指定的字符开头 + * @param str source字符串 + * @param {String} start 指定的字符 + * @returns {String} 以指定字符开头的字符串 + */ + const perfectStart: _perfectStart; + + /** + * 获取字符串中某字符串的所有项位置数组 + * @param str source字符串 + * @param {String} sub 子字符串 + * @return {Number[]} 子字符串在父字符串中出现的所有位置组成的数组 + */ + const allIndexOf: _allIndexOf; } From 5f1709e9cca9747bf90a6f54ceb2446b1aafc2ba Mon Sep 17 00:00:00 2001 From: alan Date: Fri, 5 Jul 2019 10:30:10 +0800 Subject: [PATCH 3/3] =?UTF-8?q?docs:=20=E8=B0=83=E6=95=B4=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- typescript/core/func/string.ts | 43 +++++++++++++++++++++++++++++ typescript/index.ts | 49 ---------------------------------- 2 files changed, 43 insertions(+), 49 deletions(-) diff --git a/typescript/core/func/string.ts b/typescript/core/func/string.ts index fae4d7d66..b8d8f3074 100644 --- a/typescript/core/func/string.ts +++ b/typescript/core/func/string.ts @@ -1,13 +1,56 @@ +/** + * 判断字符串是否已指定的字符串开始 + * @param str source字符串 + * @param {String} startTag 指定的开始字符串 + * @return {Boolean} 如果字符串以指定字符串开始则返回true,否则返回false + */ export declare type _startWith = (str: string, startTag: string) => boolean; +/** + * 判断字符串是否以指定的字符串结束 + * @param str source字符串 + * @param {String} endTag 指定的字符串 + * @return {Boolean} 如果字符串以指定字符串结束则返回true,否则返回false + */ export declare type _endWith = (str: string, endTag: string) => boolean; +/** + * 获取url中指定名字的参数 + * @param str source字符串 + * @param {String} name 参数的名字 + * @return {String} 参数的值 + */ export declare type _getQuery = (str: string, name: string) => string|null; +/** + * 给url加上给定的参数 + * @param str source字符串 + * @param {Object} paras 参数对象,是一个键值对对象 + * @return {String} 添加了给定参数的url + */ export declare type _appendQuery = (str: string, paras: {[key: string]: string|number}) => string; +/** + * 将所有符合第一个字符串所表示的字符串替换成为第二个字符串 + * @param str source字符串 + * @param {String} s1 要替换的字符串的正则表达式 + * @param {String} s2 替换的结果字符串 + * @returns {String} 替换后的字符串 + */ export declare type _replaceAll = (str: string, s1: string, s2: string) => string; +/** + * 总是让字符串以指定的字符开头 + * @param str source字符串 + * @param {String} start 指定的字符 + * @returns {String} 以指定字符开头的字符串 + */ export declare type _perfectStart = (str: string, start: string) => string; +/** + * 获取字符串中某字符串的所有项位置数组 + * @param str source字符串 + * @param {String} sub 子字符串 + * @return {Number[]} 子字符串在父字符串中出现的所有位置组成的数组 + */ export declare type _allIndexOf = (str: string, sub: string) => number[]; diff --git a/typescript/index.ts b/typescript/index.ts index 4d17a6bb6..92ff0b0c5 100644 --- a/typescript/index.ts +++ b/typescript/index.ts @@ -15,60 +15,11 @@ export declare module BI { const pushDistinct: _pushDistinct; const pushDistinctArray: _pushDistinctArray; - /** - * 判断字符串是否已指定的字符串开始 - * @param str source字符串 - * @param {String} startTag 指定的开始字符串 - * @return {Boolean} 如果字符串以指定字符串开始则返回true,否则返回false - */ const startWith: _startWith; - - /** - * 判断字符串是否以指定的字符串结束 - * @param str source字符串 - * @param {String} endTag 指定的字符串 - * @return {Boolean} 如果字符串以指定字符串结束则返回true,否则返回false - */ const endWith: _endWith; - - /** - * 获取url中指定名字的参数 - * @param str source字符串 - * @param {String} name 参数的名字 - * @return {String} 参数的值 - */ const getQuery: _getQuery; - - /** - * 给url加上给定的参数 - * @param str source字符串 - * @param {Object} paras 参数对象,是一个键值对对象 - * @return {String} 添加了给定参数的url - */ const appendQuery: _appendQuery; - - /** - * 将所有符合第一个字符串所表示的字符串替换成为第二个字符串 - * @param str source字符串 - * @param {String} s1 要替换的字符串的正则表达式 - * @param {String} s2 替换的结果字符串 - * @returns {String} 替换后的字符串 - */ const replaceAll: _replaceAll; - - /** - * 总是让字符串以指定的字符开头 - * @param str source字符串 - * @param {String} start 指定的字符 - * @returns {String} 以指定字符开头的字符串 - */ const perfectStart: _perfectStart; - - /** - * 获取字符串中某字符串的所有项位置数组 - * @param str source字符串 - * @param {String} sub 子字符串 - * @return {Number[]} 子字符串在父字符串中出现的所有位置组成的数组 - */ const allIndexOf: _allIndexOf; }