From 7653232e2d3a007125e99f55969ccd6618153098 Mon Sep 17 00:00:00 2001 From: cssmagic Date: Thu, 1 Dec 2016 17:01:08 +0800 Subject: [PATCH] Remove `gearbox.str.uniq()` API. --- dist/gearbox.js | 24 ++++++++---------------- dist/gearbox.min.js | 4 ++-- doc/api-str.zh.md | 25 ------------------------- package.json | 2 +- src/str.js | 10 ---------- test/test-str.js | 6 ------ 6 files changed, 11 insertions(+), 60 deletions(-) diff --git a/dist/gearbox.js b/dist/gearbox.js index 54d21a8..369a16f 100644 --- a/dist/gearbox.js +++ b/dist/gearbox.js @@ -1,4 +1,4 @@ -/*! Gearbox | MIT | https://github.com/CMUI/gearbox */ +/*! Gearbox | MIT License | https://github.com/CMUI/gearbox */ !function (window, undefined) { // check conflict if (window.gearbox) return false @@ -23,11 +23,6 @@ var document = window.document void function (window, gearbox) { 'use strict' - /** - * bind a set of apis to a key of `_` as namespace - * @param moduleName {string} - * @param apiSet {object} - */ gearbox.__defineModule = function (moduleName, apiSet) { if (!moduleName || !_.isString(moduleName) || !apiSet || !_.isObject(apiSet)) return @@ -45,6 +40,7 @@ void function (window, gearbox) { }(window, gearbox) +; //////////////////// str //////////////////// void function (window, gearbox) { @@ -156,16 +152,6 @@ void function (window, gearbox) { return str } - // array of string - str.uniq = str.unique = function (arr) { - if (!_.isArray(arr)) return false - var obj = {} - _.each(arr, function (str) { - obj[String(str)] = null - }) - return _.keys(obj) - } - // more `toNumber` methods str.toFloat = function (str) {return parseFloat(str)} str.toInt = function (str) { @@ -179,6 +165,7 @@ void function (window, gearbox) { }(window, gearbox) +; //////////////////// root //////////////////// void function (window, gearbox) { @@ -202,6 +189,7 @@ void function (window, gearbox) { }(window, gearbox) +; //////////////////// ua //////////////////// void function (window, gearbox) { @@ -364,6 +352,7 @@ void function (window, gearbox) { }(window, gearbox) +; //////////////////// url //////////////////// void function (window, gearbox) { @@ -451,6 +440,7 @@ void function (window, gearbox) { }(window, gearbox) +; //////////////////// dom //////////////////// void function (window, gearbox) { @@ -482,6 +472,7 @@ void function (window, gearbox) { }(window, gearbox) +; //////////////////// action //////////////////// // include and wrap external module: Action @@ -619,6 +610,7 @@ var action = (function () { gearbox.__defineModule('action', action) }(window, gearbox) +; //////////////////// template //////////////////// // include and wrap external module: Underscore-template diff --git a/dist/gearbox.min.js b/dist/gearbox.min.js index ba33fd3..8fe9b41 100644 --- a/dist/gearbox.min.js +++ b/dist/gearbox.min.js @@ -1,2 +1,2 @@ -/*! Gearbox | MIT | https://github.com/CMUI/gearbox */ -!function(e,t){if(e.gearbox)return!1;var n=e._,r=e.Zepto||e.jQuery||e.$;if(!n||!r)return!1;var i={},o=e.document;void function(e,t){"use strict";t.__defineModule=function(e,r){e&&n.isString(e)&&r&&n.isObject(r)&&("root"===e?n.each(r,function(e,n){t[n]=e}):t[e]=r)}}(e,i),void function(e,t){"use strict";function r(e){return null==e?"":""+e}function i(e){return 0>e?0:+e||0}function o(e){return null==e?"\\s":e.source?e.source:"["+s.escapeRegExp(e)+"]"}var s={},u=String.prototype.trim,a=String.prototype.trimRight,c=String.prototype.trimLeft;s.escapeRegExp=function(e){return null==e?"":r(e).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")},s.trim=function(e,t){return null==e?"":!t&&u?u.call(e):(t=o(t),r(e).replace(new RegExp("^"+t+"+|"+t+"+$","g"),""))},s.ltrim=function(e,t){return null==e?"":!t&&c?c.call(e):(t=o(t),r(e).replace(new RegExp("^"+t+"+"),""))},s.rtrim=function(e,t){return null==e?"":!t&&a?a.call(e):(t=o(t),r(e).replace(new RegExp(t+"+$"),""))},s.includes=function(e,t,n){return""===t?!0:(n=null==n?0:Math.min(i(n),e.length),-1!==r(e).slice(n).indexOf(t))},s.startsWith=function(e,t,n){return e=r(e),t=""+t,n=null==n?0:Math.min(i(n),e.length),e.lastIndexOf(t,n)===n},s.endsWith=function(e,t,n){return e=r(e),t=""+t,n="undefined"==typeof n?e.length-t.length:Math.min(i(n),e.length)-t.length,n>=0&&e.indexOf(t,n)===n},s.contains=s.includes,s.include=s.includes,s.CNY=s.RMB="¥",s.FULL_WIDTH_CNY=s.FULL_WIDTH_RMB="¥",s.RE_EMAIL=/^(?:[a-z\d]+[_\-\+\.]?)*[a-z\d]+@(?:([a-z\d]+\-?)*[a-z\d]+\.)+([a-z]{2,})+$/i,s.RE_MOBILE=/^1[34578]\d{9}$/,s.RE_POSTCODE=/^\d{6}$/,s.isHash=function(e){return e=t.str.trim(e),t.str.startsWith(e,"#")},s.stripHash=function(e){return e=t.str.trim(e),e=t.str.ltrim(e,"#"),t.str.startsWith(e,"!")&&(e=e.slice(1)),e},s.uniq=s.unique=function(e){if(!n.isArray(e))return!1;var t={};return n.each(e,function(e){t[String(e)]=null}),n.keys(t)},s.toFloat=function(e){return parseFloat(e)},s.toInt=function(e){var t=parseFloat(e);return 0>t?Math.ceil(t):Math.floor(t)},s.toFixed=function(e,n){return t.str.toFloat(t.str.toFloat(e).toFixed(n||0))},t.__defineModule("str",s)}(e,i),void function(e,t){"use strict";var i={$:function(e){var i;return i=n.isElement(e)?e.__$__=e.__$__||r(e):t.dom.is$Element(e)?e:r(e)}};t.__defineModule("root",i)}(e,i),void function(e,t){"use strict";function r(e){var n=e.str.toLowerCase(),r=t.str.includes;if(e.isSafari=/\bapple\b/i.test(navigator.vendor)&&/\bsafari\b/i.test(n),e.isChrome=r(n,"chrome")||r(n,"crios"),e.osVersion="",e.isIOS=/\(i(?:phone|pod|pad)\b/.test(n)||/\bios \d+\./.test(n),e.isIOS)e.isIPad=/\(ipad\b/.test(n),e.isIPod=/\(ipod\b/.test(n),e.isIPhone=/\(iphone\b/.test(n),e.osVersion=(/[\/; i]os[\/: _](\d+(?:[\._]\d+)?)[\._; ]/.exec(n)||[0,""])[1].replace("_",".");else{var o=r(n,"android"),s=/\badr\b/.test(n)&&/\blinux;\s*u;/.test(n),u=/juc\s*\(linux;\s*u;\s*\d+\.\d+/.test(n);e.isAndroid=o||s||u,e.osVersion=s||u?(/\badr[\/: ]?(\d+\.\d)\d*\b/.exec(n)||/\blinux;\s*u;\s*(\d+\.\d)\d*\b/.exec(n)||[0,""])[1]:(/\bandroid(?:_os)?[\/: ]?(\d+\.\d)\d*\b/.exec(n)||[0,""])[1]}r(n,"windows phone")&&(e.isIOS=e.isAndroid=!1,e.osVersion=""),e.osVersion&&!r(e.osVersion,".")&&(e.osVersion+=".0"),e.isMobileDevice=!(!e.isIOS&&!e.isAndroid);var a="";r(n,"micromessenger")?a="wechat":r(n,"ucbrowser")||r(n,"ucweb")||r(n," uc applewebkit")?a="uc":r(n,"baiduhd")||r(n,"baiduboxapp")?a="baidu-app":r(n,"baidubrowser")?a="baidu-browser":r(n,"mqqbrowser")?a="m-qq-browser":r(n,"miuibrowser")?a="miui":r(n,"_weibo_")||r(n," weibo ")?a="weibo":r(n,"firefox")?a="firefox":r(n,"opera")?a="opera":r(n," edge/")?a="edge":r(n,"iemobile")?a="ie-mobile":e.isChrome?(a="chrome",e.isAndroid&&/\bwv\b/.test(n)&&(a="chrome-webview")):e.isSafari&&(a="safari"),"chrome"!==a&&(e.isChrome=!1),"safari"!==a&&(e.isSafari=!1);var c="",d="",l=/chrome[^\d]*([\.\d]*)[ ;\/]/.exec(n);if(l)c="chrome",d=i(l[1]);else{var f=/webkit[^\d]*([\.\d]*)\+*[ ;\/]/.exec(n);f&&(c="webkit",d=i(f[1]))}return c||(r(n,"webkit")?c="webkit":e.isIOS?c="webkit":e.isAndroid&&"m-qq-browser"===a&&(c="webkit"),"firefox"!==a||e.isIOS||(c="gecko"),"opera"===a&&!e.isIOS&&r(n,"presto")&&(c="presto")),"edge"===a?(c="edge",d=""):"ie-mobile"===a&&(c=d=""),e.browser=a,e.engine=c,e.engineVersion=d,e}function i(e,t){var r=e.split(".");return r.length=t||2,n.compact(r).join(".")}var o={};o.isTouchDevice="ontouchstart"in e&&"ontouchmove"in e&&"ontouchend"in e,o.str=navigator.userAgent,r(o),t.__defineModule("ua",o)}(e,i),void function(e,t){"use strict";function i(){return s.search.slice(1)}var o={},s=e.location;o.parseQuery=function(e){var t={};if(e&&n.isString(e)){var r,i,o,s=e.split("&");n.each(s,function(e){r=e.split("="),i=r[0],o=r[1]||"",i&&(t[decodeURIComponent(i).toLowerCase()]=decodeURIComponent(o))})}return t};var u,a=null;o.getParam=function(e){if(!e||!n.isString(e))return!1;if("undefined"==typeof u)u=i();else{var t=i();t!==u&&(a=null,u=t)}return a||(a=this.parseQuery(u)),a[e.toLowerCase()]},o.appendParam=function(e,i){var o="";return e=n.isString(e)?e:"",e=t.url.removeHashFromUrl(e),r.isPlainObject(i)?i=r.param(i):n.isString(i)?(t.str.startsWith(i,"&")||t.str.startsWith(i,"?"))&&(i=i.slice(1)):i=null,o=i?e+(t.str.includes(e,"?")?"&":"?")+i:o,o||!1},o.removeHashFromUrl=function(e){return arguments.length?String(e).split("#")[0]:""},o.getHashFromUrl=function(e){var t=String(e).split("#");return t[0]="",t.join("#")},o.isHash=t.str.isHash,o.stripHash=t.str.stripHash,t.__defineModule("url",o)}(e,i),void function(e,t){"use strict";var i={};i.$win=r(e),i.$root=r(o.documentElement),i.$body=r(o.body),i.is$Element=function(e){if(!e||!n.isObject(e))return!1;var t=!1;if("__proto__"in e)t=e.__proto__===r.fn;else{var i=r.zepto&&r.zepto.Z||r;t=e instanceof i}return t},t.__defineModule("dom",i)}(e,i),void function(e,t){"use strict";var n=function(){function t(e){var t=e.attr("data-action")||"";if(!t){var i=r.trim(e.attr("href"));i&&0===i.indexOf("#")&&(t=i)}return n(t)}function n(e){return e?r.trim(String(e).replace(/^[#!\s]+/,"")):""}function i(){var e=r(o.body||o.documentElement);e.on("click",d,function(e){e.preventDefault();var n=r(this),i=t(n);s(i,this)})}function s(t,n){if(t){var i=l[t];return i&&r.isFunction(i)?i.call(n||e):void 0}}function u(e){r.isPlainObject(e)&&r.each(e,function(e,t){var i=n(e);i&&r.isFunction(t)&&(l[i]=t)})}function a(e,t){return s(n(e),t)}var c={},d="[data-action]",l={};return i(),c.add=u,c.trigger=a,c}();t.__defineModule("action",n)}(e,i),void function(e,t){"use strict";var r=function(){function e(e){return e.replace(/^\s+|\s+$/g,"")}function t(e,t){return e.length>t.length?0===e.indexOf(t):!1}function r(t){return t=t&&n.isString(t)?e(t).replace(/^[#!]+/,""):"",e(t).replace(d,"")}function i(r){return r=r&&n.isString(r)?e(r):"",t(r,d)?r:d+r}function s(t){if(!t)return!1;var n="",r=i(String(t)),s=o.getElementById(r);return s&&(n=e(s.innerHTML)),n}function u(e,t){var n=!1;if(arguments.length<2)return n;if(t){var i=r(e);f[i]&&(f[i]=null),l[i]=String(t),n=!0}return n}function a(e,t){var i="";if(arguments.length<2)return i;var o=r(e),u=f[o],a=l[o];return n.isFunction(u)?i=u(t):a?(u=n.template(a),f[o]=u,i=u(t),l[o]=null):(a=s(o),a&&(u=n.template(a),f[o]=u,i=u(t))),i||""}var c={},d="template-",l={},f={};return c.add=u,c.render=a,c}();t.__defineModule("template",r)}(e,i),e.gearbox=i}(window); \ No newline at end of file +/*! Gearbox | MIT License | https://github.com/CMUI/gearbox */ +!function(e,t){if(e.gearbox)return!1;var r=e._,n=e.Zepto||e.jQuery||e.$;if(!r||!n)return!1;var i={},o=e.document;void function(e,t){"use strict";t.__defineModule=function(e,n){e&&r.isString(e)&&n&&r.isObject(n)&&("root"===e?r.each(n,function(e,r){t[r]=e}):t[e]=n)}}(e,i),void function(e,t){"use strict";function r(e){return null==e?"":""+e}function n(e){return e<0?0:+e||0}function i(e){return null==e?"\\s":e.source?e.source:"["+o.escapeRegExp(e)+"]"}var o={},s=String.prototype.trim,u=String.prototype.trimRight,a=String.prototype.trimLeft;o.escapeRegExp=function(e){return null==e?"":r(e).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")},o.trim=function(e,t){return null==e?"":!t&&s?s.call(e):(t=i(t),r(e).replace(new RegExp("^"+t+"+|"+t+"+$","g"),""))},o.ltrim=function(e,t){return null==e?"":!t&&a?a.call(e):(t=i(t),r(e).replace(new RegExp("^"+t+"+"),""))},o.rtrim=function(e,t){return null==e?"":!t&&u?u.call(e):(t=i(t),r(e).replace(new RegExp(t+"+$"),""))},o.includes=function(e,t,i){return""===t||(i=null==i?0:Math.min(n(i),e.length),r(e).slice(i).indexOf(t)!==-1)},o.startsWith=function(e,t,i){return e=r(e),t=""+t,i=null==i?0:Math.min(n(i),e.length),e.lastIndexOf(t,i)===i},o.endsWith=function(e,t,i){return e=r(e),t=""+t,i="undefined"==typeof i?e.length-t.length:Math.min(n(i),e.length)-t.length,i>=0&&e.indexOf(t,i)===i},o.contains=o.includes,o.include=o.includes,o.CNY=o.RMB="¥",o.FULL_WIDTH_CNY=o.FULL_WIDTH_RMB="¥",o.RE_EMAIL=/^(?:[a-z\d]+[_\-\+\.]?)*[a-z\d]+@(?:([a-z\d]+\-?)*[a-z\d]+\.)+([a-z]{2,})+$/i,o.RE_MOBILE=/^1[34578]\d{9}$/,o.RE_POSTCODE=/^\d{6}$/,o.isHash=function(e){return e=t.str.trim(e),t.str.startsWith(e,"#")},o.stripHash=function(e){return e=t.str.trim(e),e=t.str.ltrim(e,"#"),t.str.startsWith(e,"!")&&(e=e.slice(1)),e},o.toFloat=function(e){return parseFloat(e)},o.toInt=function(e){var t=parseFloat(e);return t<0?Math.ceil(t):Math.floor(t)},o.toFixed=function(e,r){return t.str.toFloat(t.str.toFloat(e).toFixed(r||0))},t.__defineModule("str",o)}(e,i),void function(e,t){"use strict";var i={$:function(e){var i;return i=r.isElement(e)?e.__$__=e.__$__||n(e):t.dom.is$Element(e)?e:n(e)}};t.__defineModule("root",i)}(e,i),void function(e,t){"use strict";function n(e){var r=e.str.toLowerCase(),n=t.str.includes;if(e.isSafari=/\bapple\b/i.test(navigator.vendor)&&/\bsafari\b/i.test(r),e.isChrome=n(r,"chrome")||n(r,"crios"),e.osVersion="",e.isIOS=/\(i(?:phone|pod|pad)\b/.test(r)||/\bios \d+\./.test(r),e.isIOS)e.isIPad=/\(ipad\b/.test(r),e.isIPod=/\(ipod\b/.test(r),e.isIPhone=/\(iphone\b/.test(r),e.osVersion=(/[\/; i]os[\/: _](\d+(?:[\._]\d+)?)[\._; ]/.exec(r)||[0,""])[1].replace("_",".");else{var o=n(r,"android"),s=/\badr\b/.test(r)&&/\blinux;\s*u;/.test(r),u=/juc\s*\(linux;\s*u;\s*\d+\.\d+/.test(r);e.isAndroid=o||s||u,s||u?e.osVersion=(/\badr[\/: ]?(\d+\.\d)\d*\b/.exec(r)||/\blinux;\s*u;\s*(\d+\.\d)\d*\b/.exec(r)||[0,""])[1]:e.osVersion=(/\bandroid(?:_os)?[\/: ]?(\d+\.\d)\d*\b/.exec(r)||[0,""])[1]}n(r,"windows phone")&&(e.isIOS=e.isAndroid=!1,e.osVersion=""),e.osVersion&&!n(e.osVersion,".")&&(e.osVersion+=".0"),e.isMobileDevice=!(!e.isIOS&&!e.isAndroid);var a="";n(r,"micromessenger")?a="wechat":n(r,"ucbrowser")||n(r,"ucweb")||n(r," uc applewebkit")?a="uc":n(r,"baiduhd")||n(r,"baiduboxapp")?a="baidu-app":n(r,"baidubrowser")?a="baidu-browser":n(r,"mqqbrowser")?a="m-qq-browser":n(r,"miuibrowser")?a="miui":n(r,"_weibo_")||n(r," weibo ")?a="weibo":n(r,"firefox")?a="firefox":n(r,"opera")?a="opera":n(r," edge/")?a="edge":n(r,"iemobile")?a="ie-mobile":e.isChrome?(a="chrome",e.isAndroid&&/\bwv\b/.test(r)&&(a="chrome-webview")):e.isSafari&&(a="safari"),"chrome"!==a&&(e.isChrome=!1),"safari"!==a&&(e.isSafari=!1);var c="",d="",l=/chrome[^\d]*([\.\d]*)[ ;\/]/.exec(r);if(l)c="chrome",d=i(l[1]);else{var f=/webkit[^\d]*([\.\d]*)\+*[ ;\/]/.exec(r);f&&(c="webkit",d=i(f[1]))}return c||(n(r,"webkit")?c="webkit":e.isIOS?c="webkit":e.isAndroid&&"m-qq-browser"===a&&(c="webkit"),"firefox"!==a||e.isIOS||(c="gecko"),"opera"===a&&!e.isIOS&&n(r,"presto")&&(c="presto")),"edge"===a?(c="edge",d=""):"ie-mobile"===a&&(c=d=""),e.browser=a,e.engine=c,e.engineVersion=d,e}function i(e,t){var n=e.split(".");return n.length=t||2,r.compact(n).join(".")}var o={};o.isTouchDevice="ontouchstart"in e&&"ontouchmove"in e&&"ontouchend"in e,o.str=navigator.userAgent,n(o),t.__defineModule("ua",o)}(e,i),void function(e,t){"use strict";function i(){return s.search.slice(1)}var o={},s=e.location;o.parseQuery=function(e){var t={};if(e&&r.isString(e)){var n,i,o,s=e.split("&");r.each(s,function(e){n=e.split("="),i=n[0],o=n[1]||"",i&&(t[decodeURIComponent(i).toLowerCase()]=decodeURIComponent(o))})}return t};var u,a=null;o.getParam=function(e){if(!e||!r.isString(e))return!1;if("undefined"==typeof u)u=i();else{var t=i();t!==u&&(a=null,u=t)}return a||(a=this.parseQuery(u)),a[e.toLowerCase()]},o.appendParam=function(e,i){var o="";return e=r.isString(e)?e:"",e=t.url.removeHashFromUrl(e),n.isPlainObject(i)?i=n.param(i):r.isString(i)?(t.str.startsWith(i,"&")||t.str.startsWith(i,"?"))&&(i=i.slice(1)):i=null,o=i?e+(t.str.includes(e,"?")?"&":"?")+i:o,o||!1},o.removeHashFromUrl=function(e){return arguments.length?String(e).split("#")[0]:""},o.getHashFromUrl=function(e){var t=String(e).split("#");return t[0]="",t.join("#")},o.isHash=t.str.isHash,o.stripHash=t.str.stripHash,t.__defineModule("url",o)}(e,i),void function(e,t){"use strict";var i={};i.$win=n(e),i.$root=n(o.documentElement),i.$body=n(o.body),i.is$Element=function(e){if(!e||!r.isObject(e))return!1;var t=!1;if("__proto__"in e)t=e.__proto__===n.fn;else{var i=n.zepto&&n.zepto.Z||n;t=e instanceof i}return t},t.__defineModule("dom",i)}(e,i),void function(e,t){"use strict";var r=function(){function t(e){var t=e.attr("data-action")||"";if(!t){var i=n.trim(e.attr("href"));i&&0===i.indexOf("#")&&(t=i)}return r(t)}function r(e){return e?n.trim(String(e).replace(/^[#!\s]+/,"")):""}function i(){var e=n(o.body||o.documentElement);e.on("click",d,function(e){e.preventDefault();var r=n(this),i=t(r);s(i,this)})}function s(t,r){if(t){var i=l[t];return i&&n.isFunction(i)?i.call(r||e):void 0}}function u(e){n.isPlainObject(e)&&n.each(e,function(e,t){var i=r(e);i&&n.isFunction(t)&&(l[i]=t)})}function a(e,t){return s(r(e),t)}var c={},d="[data-action]",l={};return i(),c.add=u,c.trigger=a,c}();t.__defineModule("action",r)}(e,i),void function(e,t){"use strict";var n=function(){function e(e){return e.replace(/^\s+|\s+$/g,"")}function t(e,t){return e.length>t.length&&0===e.indexOf(t)}function n(t){return t=t&&r.isString(t)?e(t).replace(/^[#!]+/,""):"",e(t).replace(d,"")}function i(n){return n=n&&r.isString(n)?e(n):"",t(n,d)?n:d+n}function s(t){if(!t)return!1;var r="",n=i(String(t)),s=o.getElementById(n);return s&&(r=e(s.innerHTML)),r}function u(e,t){var r=!1;if(arguments.length<2)return r;if(t){var i=n(e);f[i]&&(f[i]=null),l[i]=String(t),r=!0}return r}function a(e,t){var i="";if(arguments.length<2)return i;var o=n(e),u=f[o],a=l[o];return r.isFunction(u)?i=u(t):a?(u=r.template(a),f[o]=u,i=u(t),l[o]=null):(a=s(o),a&&(u=r.template(a),f[o]=u,i=u(t))),i||""}var c={},d="template-",l={},f={};return c.add=u,c.render=a,c}();t.__defineModule("template",n)}(e,i),e.gearbox=i}(window); \ No newline at end of file diff --git a/doc/api-str.zh.md b/doc/api-str.zh.md index 6fc08a9..f8ba6dd 100644 --- a/doc/api-str.zh.md +++ b/doc/api-str.zh.md @@ -119,31 +119,6 @@ gearbox.str.stripHash(' #foo-bar') // => 'foo-bar' *** -### `.uniq(array)`   - -从字符串数组中去除重复的项。 - -#### 注意事项 - -* 非字符串的值会被转换为字符串后进行比对,即 `null` 和 `'null'` 会被视为重复。 -* 去重后的各个字符串在数组中的排序无法保证。 - -#### 参数 - -* `array` -- 字符串数组。 - -#### 返回值 - -数组。去重之后的结果。 - -#### 示例 - -```js -gearbox.str.uniq(['foo', 'foo', 'bar']) // => ['foo', 'bar'] -``` - -*** - ### `.toFloat(string)`   转换为浮点数。 diff --git a/package.json b/package.json index dbf7a3a..8fa4f6a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cmui-gearbox", - "version": "0.6.0", + "version": "0.7.0", "homepage": "https://github.com/CMUI/gearbox", "author": "cssmagic ", "description": "Lightweight JavaScript utilities for web development.", diff --git a/src/str.js b/src/str.js index 38ca407..14b3895 100644 --- a/src/str.js +++ b/src/str.js @@ -109,16 +109,6 @@ void function (window, gearbox) { return str } - // array of string - str.uniq = str.unique = function (arr) { - if (!_.isArray(arr)) return false - var obj = {} - _.each(arr, function (str) { - obj[String(str)] = null - }) - return _.keys(obj) - } - // more `toNumber` methods str.toFloat = function (str) {return parseFloat(str)} str.toInt = function (str) { diff --git a/test/test-str.js b/test/test-str.js index caa7171..ef6e1c4 100644 --- a/test/test-str.js +++ b/test/test-str.js @@ -364,12 +364,6 @@ describe('String', function () { }) }) - describe('String Array', function () { - describe('gearbox.str.uniq()', function () { - it('(dummy test)', function () {}) - }) - }) - describe('To Number', function () { describe('gearbox.str.toFloat()', function () { it('does basic functionality', function () {