Comparing version 1.0.0 to 1.0.1
@@ -730,2 +730,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
* // => true | ||
* | ||
* isArray({}) | ||
@@ -763,2 +764,3 @@ * // => false | ||
* // => true | ||
* | ||
* isBoolean([]) | ||
@@ -842,2 +844,3 @@ * // => false | ||
* // => true | ||
* | ||
* isNumber([]) | ||
@@ -875,2 +878,3 @@ * // => false | ||
* // => true | ||
* | ||
* isObject(123) | ||
@@ -908,2 +912,3 @@ * // => false | ||
* // => true | ||
* | ||
* isString([]) | ||
@@ -1045,3 +1050,3 @@ * // => false | ||
/** | ||
* Method to sum two numbers. | ||
* Set query to url. | ||
* | ||
@@ -1088,7 +1093,8 @@ * @since 0.3.0 | ||
var newQueryString = Object.keys(newQueryObject).map(function (key) { | ||
var fieldValue = key && newQueryObject[key] ? "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(newQueryObject[key])) : ''; | ||
return Array.isArray(newQueryObject[key]) ? newQueryObject[key].map(function (value) { | ||
return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value)); | ||
}).join('&') : "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(newQueryObject[key])); | ||
return value && key ? "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value)) : ''; | ||
}).join('&') : fieldValue; | ||
}).join('&'); | ||
window.history.pushState('', '', "?".concat(decodeURIComponent(newQueryString))); | ||
window.history.pushState('', '', newQueryString ? "?".concat(decodeURIComponent(newQueryString)) : ''); | ||
} | ||
@@ -1245,3 +1251,3 @@ | ||
module.exports = {"name":"chober","version":"1.0.0","description":"Chober.js - is a collection of methods that are used by programmers every day. We decided to put all the methods together so as not to copy them from project to project.","main":"dist/chober.js","scripts":{"prod":"webpack --env production --config webpack.config.js","dev":"webpack --env development --config webpack.config.js","watch":"webpack --env development --config webpack.config.js --watch","build":"npm run docs && npm run prod && npm run dev","docs":"jsdoc2md --template README.hbs --files lib/*.js > docs/README.md","docs-server":"docsify serve docs -p 35730"},"repository":{"type":"git","url":"git+https://github.com/BrooonS/chober.js.git"},"keywords":["webpack","js","javascript","library","methods","chober","isEmpty","isArray","isNumber","isString","isObject","isBoolean","getQuery","getNumbers","getScrollbarWidth","getCookie","getOffset","getType","setQuery","setCookie","removeCookie","clone","invertObject","first","formatNumber","debounce","scrollTo","uniq"],"author":"Valery Strelets","license":"MIT","bugs":{"url":"https://github.com/BrooonS/chober.js/issues"},"homepage":"https://github.com/BrooonS/chober.js#readme","devDependencies":{"@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/plugin-transform-object-assign":"^7.0.0","@babel/plugin-transform-runtime":"^7.1.0","@babel/preset-env":"^7.1.0","@babel/runtime":"^7.1.2","babel-eslint":"^10.0.1","babel-loader":"^8.0.4","docsify-cli":"^4.2.1","eslint":"^5.6.1","eslint-config-airbnb":"^17.1.0","eslint-loader":"^2.1.1","eslint-plugin-import":"^2.14.0","eslint-plugin-jsx-a11y":"^6.1.2","eslint-plugin-react":"^7.11.1","jsdoc-to-markdown":"^4.0.1","uglifyjs-webpack-plugin":"^2.0.1","webpack":"^4.20.2","webpack-cli":"^3.1.2"}}; | ||
module.exports = {"name":"chober","version":"1.0.0","description":"Chober.js - is a collection of methods that are used by programmers every day. We decided to put all the methods together so as not to copy them from project to project.","main":"dist/chober.js","scripts":{"prod":"webpack --env production --config webpack.config.js","dev":"webpack --env development --config webpack.config.js","watch":"webpack --env development --config webpack.config.js --watch","build":"npm run docs && npm run prod && npm run dev","docs":"jsdoc2md --template README.hbs --files lib/*.js > docs/README.md","docs-server":"docsify serve docs -p 35730"},"repository":{"type":"git","url":"git+https://github.com/BrooonS/chober.js.git"},"keywords":["webpack","js","javascript","library","es6","commonjs","methods","chober","isEmpty","isArray","isNumber","isString","isObject","isBoolean","getQuery","getNumbers","getScrollbarWidth","getCookie","getOffset","getType","setQuery","setCookie","removeCookie","clone","invertObject","first","formatNumber","debounce","scrollTo","uniq"],"author":"Valery Strelets","license":"MIT","bugs":{"url":"https://github.com/BrooonS/chober.js/issues"},"homepage":"https://github.com/BrooonS/chober.js#readme","devDependencies":{"@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/plugin-transform-object-assign":"^7.0.0","@babel/plugin-transform-runtime":"^7.1.0","@babel/preset-env":"^7.1.0","@babel/runtime":"^7.1.2","babel-eslint":"^10.0.1","babel-loader":"^8.0.4","docsify-cli":"^4.2.1","eslint":"^5.6.1","eslint-config-airbnb":"^17.1.0","eslint-loader":"^2.1.1","eslint-plugin-import":"^2.14.0","eslint-plugin-jsx-a11y":"^6.1.2","eslint-plugin-react":"^7.11.1","jsdoc-to-markdown":"^4.0.1","uglifyjs-webpack-plugin":"^2.0.1","webpack":"^4.20.2","webpack-cli":"^3.1.2"}}; | ||
@@ -1248,0 +1254,0 @@ /***/ }) |
@@ -1,2 +0,2 @@ | ||
!function webpackUniversalModuleDefinition(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("_c",[],r):"object"==typeof exports?exports._c=r():e._c=r()}("undefined"!=typeof self?self:this,function(){return function(t){var n={};function __webpack_require__(e){if(n[e])return n[e].exports;var r=n[e]={i:e,l:!1,exports:{}};return t[e].call(r.exports,r,r.exports,__webpack_require__),r.l=!0,r.exports}return __webpack_require__.m=t,__webpack_require__.c=n,__webpack_require__.d=function(e,r,t){__webpack_require__.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__.t=function(r,e){if(1&e&&(r=__webpack_require__(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var t=Object.create(null);if(__webpack_require__.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var n in r)__webpack_require__.d(t,n,function(e){return r[e]}.bind(null,n));return t},__webpack_require__.n=function(e){var r=e&&e.__esModule?function getDefault(){return e.default}:function getModuleExports(){return e};return __webpack_require__.d(r,"a",r),r},__webpack_require__.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=5)}([function(e,r){e.exports=function _defineProperty(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}},function(e,r,t){var o=t(0);e.exports=function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.forEach(function(e){o(r,e,t[e])})}return r}},function(e,r){function _extends(){return e.exports=_extends=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},_extends.apply(this,arguments)}e.exports=_extends},function(e,r){e.exports=function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}},function(e){e.exports={a:"1.0.0"}},function(e,r,t){"use strict";t.r(r);var n=t(2),o=t.n(n),i=t(3),c=t.n(i),u=t(4);var a=function isEmpty(e){return!(e&&(e.length||Object.keys(e).length))};var f=function getType(e){return Object.prototype.toString.call(e).replace(/^\[object (.+)\]$/,"$1").toLowerCase()};var s=function isArray(e){return"array"===f(e)};var p=function isNumber(e){return"number"===f(e)};var l=function isString(e){return"string"===f(e)};var d=function isObject(e){return"object"===f(e)};var b=function isBoolean(e){return"boolean"===f(e)},_=t(0),h=t.n(_),w=t(1),y=t.n(w);var v=function getQuery(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],r=window.location.search.substr(1),n={};return r?(e.length&&o()(n,e.reduce(function(e,r){return y()({},e,h()({},r,[]))},{})),r.split("&").forEach(function(e){var t=e.split("=");Object.prototype.hasOwnProperty.call(n,t[0])&&(s(n[t[0]])?n[t[0]].push(t[1]):n[t[0]]=[n[t[0]],t[1]]),s(n[t[0]])?n[t[0]].forEach(function(e,r){n[t[0]][r]=decodeURIComponent(e)}):n[t[0]]=decodeURIComponent(t[1])}),n):{}};var g=function getNumbers(e){if(!e)throw new Error("[chober]: string or number is not passed.");return String(e).replace(/\D+/g,"")};var m=function getScrollbarWidth(){return window.innerWidth-document.documentElement.clientWidth};var O=function getCookie(e){if(!e)throw new Error("[chober]: key is not passed.");var r="; ".concat(document.cookie).split("; ".concat(e,"="));return 2===r.length?r.pop().split(";").shift():""};var j=function getOffset(e){if(!e)throw new Error("[chober]: selector is not passed.");var r=document.querySelector(e).getBoundingClientRect(),t=window.pageXOffset,n=window.pageYOffset;return{x:r.left+t,y:r.top+n,left:r.left+t,top:r.top+n,right:r.right+t,bottom:r.bottom+n}};var k=function uniq(e){if(!e)throw new Error("[chober]: array is not passed.");return e.filter(function(e,r,t){return t.indexOf(e)===r})};var C=function setQuery(e){var r=1<arguments.length&&void 0!==arguments[1]&&arguments[1];if(!e)throw new Error("[chober]: query is not passed.");var t=v(),n=Object.entries(e).concat(Object.entries(t)),o=r&&!a(t)?n.reduce(function(e,r){var t=r[0],n=r[1];if(Object.prototype.hasOwnProperty.call(e,t)){var o=e[t]===n?n:[e[t],n],i="array"===f(e[t])?k(e[t].concat(n)):o,c="array"===f(n)?k(n.concat(e[t])):i;return y()({},e,h()({},t,c))}return y()({},e,h()({},t,n))},{}):e,i=Object.keys(o).map(function(r){return Array.isArray(o[r])?o[r].map(function(e){return"".concat(encodeURIComponent(r),"=").concat(encodeURIComponent(e))}).join("&"):"".concat(encodeURIComponent(r),"=").concat(encodeURIComponent(o[r]))}).join("&");window.history.pushState("","","?".concat(decodeURIComponent(i)))};var x=function setCookie(e,r){var t=2<arguments.length&&void 0!==arguments[2]&&arguments[2];if(!e&&!r)throw new Error("[chober]: key or value is not passed.");var n=t&&(new Date).getTime()+t,o=t&&new Date(n).toUTCString(),i="".concat(e,"=").concat(r,"; path=/"),c="; expires=".concat(o);document.cookie=t?i:i+c};var E=function removeCookie(e){if(!e)throw new Error("[chober]: key is not passed.");document.cookie="".concat(e,"=; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;")};var S=function clone(e){if(!e)throw new Error("[chober]: nothing to clone.");return e&&JSON.parse(JSON.stringify(e))};var q=function invertObject(e){if(!e)throw new Error("[chober]: object is not passed.");return e&&Object.entries(e).reduce(function(e,r){return y()({},e,h()({},r[1],r[0]))},{})};var T=function first(e){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;if(!e)throw new Error("[chober]: array is not passed.");return s(e)?e.slice(0,r):[]};var N=function formatNumber(e){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:" ";if(!e)throw new Error("[chober]: number is not passed.");return String(e).replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g,"$1".concat(r))};var P=function debounce(n,o){var i=this;if(!n&&!o)throw new Error("[chober]: function or delay is not passed.");var c=null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];c&&clearTimeout(c),c=setTimeout(function onComplete(){n.apply(i,r),c=null},o)}};var I=function scrollTo(e){if(!e)throw new Error("[chober]: element is not passed.");e.scrollIntoView({behavior:"smooth"})};t.d(r,"VERSION",function(){return R}),t.d(r,"isEmpty",function(){return a}),t.d(r,"isArray",function(){return s}),t.d(r,"isNumber",function(){return p}),t.d(r,"isString",function(){return l}),t.d(r,"isObject",function(){return d}),t.d(r,"isBoolean",function(){return b}),t.d(r,"getQuery",function(){return v}),t.d(r,"getNumbers",function(){return g}),t.d(r,"getScrollbarWidth",function(){return m}),t.d(r,"getCookie",function(){return O}),t.d(r,"getOffset",function(){return j}),t.d(r,"getType",function(){return f}),t.d(r,"setQuery",function(){return C}),t.d(r,"setCookie",function(){return x}),t.d(r,"removeCookie",function(){return E}),t.d(r,"clone",function(){return S}),t.d(r,"invertObject",function(){return q}),t.d(r,"first",function(){return T}),t.d(r,"formatNumber",function(){return N}),t.d(r,"debounce",function(){return P}),t.d(r,"scrollTo",function(){return I}),t.d(r,"uniq",function(){return k}); | ||
!function webpackUniversalModuleDefinition(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("_c",[],r):"object"==typeof exports?exports._c=r():e._c=r()}("undefined"!=typeof self?self:this,function(){return function(t){var n={};function __webpack_require__(e){if(n[e])return n[e].exports;var r=n[e]={i:e,l:!1,exports:{}};return t[e].call(r.exports,r,r.exports,__webpack_require__),r.l=!0,r.exports}return __webpack_require__.m=t,__webpack_require__.c=n,__webpack_require__.d=function(e,r,t){__webpack_require__.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__.t=function(r,e){if(1&e&&(r=__webpack_require__(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var t=Object.create(null);if(__webpack_require__.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var n in r)__webpack_require__.d(t,n,function(e){return r[e]}.bind(null,n));return t},__webpack_require__.n=function(e){var r=e&&e.__esModule?function getDefault(){return e.default}:function getModuleExports(){return e};return __webpack_require__.d(r,"a",r),r},__webpack_require__.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=5)}([function(e,r){e.exports=function _defineProperty(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}},function(e,r,t){var o=t(0);e.exports=function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.forEach(function(e){o(r,e,t[e])})}return r}},function(e,r){function _extends(){return e.exports=_extends=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},_extends.apply(this,arguments)}e.exports=_extends},function(e,r){e.exports=function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}},function(e){e.exports={a:"1.0.1"}},function(e,r,t){"use strict";t.r(r);var n=t(2),o=t.n(n),i=t(3),c=t.n(i),u=t(4);var a=function isEmpty(e){return!(e&&(e.length||Object.keys(e).length))};var f=function getType(e){return Object.prototype.toString.call(e).replace(/^\[object (.+)\]$/,"$1").toLowerCase()};var s=function isArray(e){return"array"===f(e)};var p=function isNumber(e){return"number"===f(e)};var l=function isString(e){return"string"===f(e)};var d=function isObject(e){return"object"===f(e)};var b=function isBoolean(e){return"boolean"===f(e)},_=t(0),h=t.n(_),w=t(1),y=t.n(w);var v=function getQuery(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],r=window.location.search.substr(1),n={};return r?(e.length&&o()(n,e.reduce(function(e,r){return y()({},e,h()({},r,[]))},{})),r.split("&").forEach(function(e){var t=e.split("=");Object.prototype.hasOwnProperty.call(n,t[0])&&(s(n[t[0]])?n[t[0]].push(t[1]):n[t[0]]=[n[t[0]],t[1]]),s(n[t[0]])?n[t[0]].forEach(function(e,r){n[t[0]][r]=decodeURIComponent(e)}):n[t[0]]=decodeURIComponent(t[1])}),n):{}};var g=function getNumbers(e){if(!e)throw new Error("[chober]: string or number is not passed.");return String(e).replace(/\D+/g,"")};var m=function getScrollbarWidth(){return window.innerWidth-document.documentElement.clientWidth};var O=function getCookie(e){if(!e)throw new Error("[chober]: key is not passed.");var r="; ".concat(document.cookie).split("; ".concat(e,"="));return 2===r.length?r.pop().split(";").shift():""};var j=function getOffset(e){if(!e)throw new Error("[chober]: selector is not passed.");var r=document.querySelector(e).getBoundingClientRect(),t=window.pageXOffset,n=window.pageYOffset;return{x:r.left+t,y:r.top+n,left:r.left+t,top:r.top+n,right:r.right+t,bottom:r.bottom+n}};var k=function uniq(e){if(!e)throw new Error("[chober]: array is not passed.");return e.filter(function(e,r,t){return t.indexOf(e)===r})};var C=function setQuery(e){var r=1<arguments.length&&void 0!==arguments[1]&&arguments[1];if(!e)throw new Error("[chober]: query is not passed.");var t=v(),n=Object.entries(e).concat(Object.entries(t)),o=r&&!a(t)?n.reduce(function(e,r){var t=r[0],n=r[1];if(Object.prototype.hasOwnProperty.call(e,t)){var o=e[t]===n?n:[e[t],n],i="array"===f(e[t])?k(e[t].concat(n)):o,c="array"===f(n)?k(n.concat(e[t])):i;return y()({},e,h()({},t,c))}return y()({},e,h()({},t,n))},{}):e,i=Object.keys(o).map(function(r){var e=r&&o[r]?"".concat(encodeURIComponent(r),"=").concat(encodeURIComponent(o[r])):"";return Array.isArray(o[r])?o[r].map(function(e){return e&&r?"".concat(encodeURIComponent(r),"=").concat(encodeURIComponent(e)):""}).join("&"):e}).join("&");window.history.pushState("","",i?"?".concat(decodeURIComponent(i)):"")};var x=function setCookie(e,r){var t=2<arguments.length&&void 0!==arguments[2]&&arguments[2];if(!e&&!r)throw new Error("[chober]: key or value is not passed.");var n=t&&(new Date).getTime()+t,o=t&&new Date(n).toUTCString(),i="".concat(e,"=").concat(r,"; path=/"),c="; expires=".concat(o);document.cookie=t?i:i+c};var E=function removeCookie(e){if(!e)throw new Error("[chober]: key is not passed.");document.cookie="".concat(e,"=; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;")};var S=function clone(e){if(!e)throw new Error("[chober]: nothing to clone.");return e&&JSON.parse(JSON.stringify(e))};var q=function invertObject(e){if(!e)throw new Error("[chober]: object is not passed.");return e&&Object.entries(e).reduce(function(e,r){return y()({},e,h()({},r[1],r[0]))},{})};var T=function first(e){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;if(!e)throw new Error("[chober]: array is not passed.");return s(e)?e.slice(0,r):[]};var N=function formatNumber(e){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:" ";if(!e)throw new Error("[chober]: number is not passed.");return String(e).replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g,"$1".concat(r))};var P=function debounce(n,o){var i=this;if(!n&&!o)throw new Error("[chober]: function or delay is not passed.");var c=null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];c&&clearTimeout(c),c=setTimeout(function onComplete(){n.apply(i,r),c=null},o)}};var I=function scrollTo(e){if(!e)throw new Error("[chober]: element is not passed.");e.scrollIntoView({behavior:"smooth"})};t.d(r,"VERSION",function(){return R}),t.d(r,"isEmpty",function(){return a}),t.d(r,"isArray",function(){return s}),t.d(r,"isNumber",function(){return p}),t.d(r,"isString",function(){return l}),t.d(r,"isObject",function(){return d}),t.d(r,"isBoolean",function(){return b}),t.d(r,"getQuery",function(){return v}),t.d(r,"getNumbers",function(){return g}),t.d(r,"getScrollbarWidth",function(){return m}),t.d(r,"getCookie",function(){return O}),t.d(r,"getOffset",function(){return j}),t.d(r,"getType",function(){return f}),t.d(r,"setQuery",function(){return C}),t.d(r,"setCookie",function(){return x}),t.d(r,"removeCookie",function(){return E}),t.d(r,"clone",function(){return S}),t.d(r,"invertObject",function(){return q}),t.d(r,"first",function(){return T}),t.d(r,"formatNumber",function(){return N}),t.d(r,"debounce",function(){return P}),t.d(r,"scrollTo",function(){return I}),t.d(r,"uniq",function(){return k}); | ||
/** | ||
@@ -3,0 +3,0 @@ * Chober.js - is a collection of useful methods that are used by programmers every day. |
![logo](_media/logo.png) | ||
# Chober <small>1.0.0</small> | ||
# Chober <small>1.0.1</small> | ||
@@ -5,0 +5,0 @@ > Is a collection of useful methods. |
@@ -15,3 +15,3 @@ # Chober.js | ||
Install with [npm](https://npmjs.com/). | ||
Install with [npm](https://www.npmjs.com/package/chober). | ||
@@ -35,3 +35,3 @@ ```sh | ||
<!-- With version --> | ||
<script src="https://cdn.jsdelivr.net/npm/chober@1.0.0/dist/chober.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/chober@1.0.1/dist/chober.min.js"></script> | ||
``` | ||
@@ -129,4 +129,7 @@ | ||
```JS | ||
clone([1, null, '3']) // => [1, null, '3'] | ||
clone([1, null, '3']) | ||
// => [1, null, '3'] | ||
``` | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/clone.js" target="_blank">Source code</a> | ||
* * * | ||
### debounce | ||
@@ -142,7 +145,7 @@ | ||
- Type: `function` | ||
- `delay` | ||
- Type: `Number` | ||
#### Returns | ||
@@ -153,4 +156,8 @@ - `function` | ||
```JS | ||
window.addEventListener('scroll', debounce(() => { console.log(Math.random()); }, 100)); | ||
window.addEventListener('scroll', debounce(() => { | ||
console.log(Math.random()); | ||
}, 100)); | ||
``` | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/debounce.js" target="_blank">Source code</a> | ||
* * * | ||
### first | ||
@@ -166,3 +173,3 @@ | ||
- Type: `Array` | ||
- `number` | ||
@@ -177,4 +184,10 @@ - Type: `Number` | ||
```JS | ||
first([1, null, '3']) // => [1] first([1, null, '3'], 2) // => [1, null] | ||
first([1, null, '3']) | ||
// => [1] | ||
first([1, null, '3'], 2) | ||
// => [1, null] | ||
``` | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/first.js" target="_blank">Source code</a> | ||
* * * | ||
### formatNumber | ||
@@ -190,3 +203,3 @@ | ||
- Type: `Number,String` | ||
- `symbol` | ||
@@ -201,4 +214,10 @@ - Type: `String` | ||
```JS | ||
formatNumer(1234) // => '1 234' formatNumer('1234', ',') // => '1,234' | ||
formatNumer(1234) | ||
// => '1 234' | ||
formatNumer('1234', ',') | ||
// => '1,234' | ||
``` | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/formatNumber.js" target="_blank">Source code</a> | ||
* * * | ||
### getCookie | ||
@@ -223,2 +242,4 @@ | ||
``` | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/getCookie.js" target="_blank">Source code</a> | ||
* * * | ||
### getNumbers | ||
@@ -241,4 +262,7 @@ | ||
```JS | ||
getNumbers('+7 (123) 456-78-90') // => '71234567890' | ||
getNumbers('+7 (123) 456-78-90') | ||
// => '71234567890' | ||
``` | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/getNumbers.js" target="_blank">Source code</a> | ||
* * * | ||
### getOffset | ||
@@ -261,4 +285,7 @@ | ||
```JS | ||
getOffset('#element').left // => 8 | ||
getOffset('#element').left | ||
// => 8 | ||
``` | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/getOffset.js" target="_blank">Source code</a> | ||
* * * | ||
### getQuery | ||
@@ -281,4 +308,9 @@ | ||
```JS | ||
// http://github.com/?value=test&field=hi&field=hello getQuery() // => { value: 'test', field: ['hi', 'hello'] } | ||
// http://github.com/?value=test&field=hi&field=hello | ||
getQuery() | ||
// => { value: 'test', field: ['hi', 'hello'] } | ||
``` | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/getQuery.js" target="_blank">Source code</a> | ||
* * * | ||
### getScrollbarWidth | ||
@@ -295,2 +327,4 @@ | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/getScrollbarWidth.js" target="_blank">Source code</a> | ||
* * * | ||
### getType | ||
@@ -313,4 +347,10 @@ | ||
```JS | ||
getType({}) // => 'object' getType([]) // => 'array' | ||
getType({}) | ||
// => 'object' | ||
getType([]) | ||
// => 'array' | ||
``` | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/getType.js" target="_blank">Source code</a> | ||
* * * | ||
### invertObject | ||
@@ -333,4 +373,7 @@ | ||
```JS | ||
invertObject({ key: 'value' }) // => { value: 'key' } | ||
invertObject({ key: 'value' }) | ||
// => { value: 'key' } | ||
``` | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/invertObject.js" target="_blank">Source code</a> | ||
* * * | ||
### isArray | ||
@@ -353,5 +396,8 @@ | ||
// => true | ||
isArray({}) | ||
// => false | ||
``` | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/isArray.js" target="_blank">Source code</a> | ||
* * * | ||
### isBoolean | ||
@@ -374,5 +420,8 @@ | ||
// => true | ||
isBoolean([]) | ||
// => false | ||
``` | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/isBoolean.js" target="_blank">Source code</a> | ||
* * * | ||
### isEmpty | ||
@@ -395,4 +444,25 @@ | ||
```JS | ||
isEmpty({ test: 'some value' }) // => false isEmpty([1, null, '3']) // => false isEmpty('qwe') // => false isEmpty(true) // => true isEmpty(1) // => true isEmpty(undefined) // => true isEmpty(null) // => true | ||
isEmpty({ test: 'some value' }) | ||
// => false | ||
isEmpty([1, null, '3']) | ||
// => false | ||
isEmpty('qwe') | ||
// => false | ||
isEmpty(true) | ||
// => true | ||
isEmpty(1) | ||
// => true | ||
isEmpty(undefined) | ||
// => true | ||
isEmpty(null) | ||
// => true | ||
``` | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/isEmpty.js" target="_blank">Source code</a> | ||
* * * | ||
### isNumber | ||
@@ -415,5 +485,8 @@ | ||
// => true | ||
isNumber([]) | ||
// => false | ||
``` | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/isNumber.js" target="_blank">Source code</a> | ||
* * * | ||
### isObject | ||
@@ -436,5 +509,8 @@ | ||
// => true | ||
isObject(123) | ||
// => false | ||
``` | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/isObject.js" target="_blank">Source code</a> | ||
* * * | ||
### isString | ||
@@ -457,5 +533,8 @@ | ||
// => true | ||
isString([]) | ||
// => false | ||
``` | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/isString.js" target="_blank">Source code</a> | ||
* * * | ||
### removeCookie | ||
@@ -478,2 +557,4 @@ | ||
``` | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/removeCookie.js" target="_blank">Source code</a> | ||
* * * | ||
### scrollTo | ||
@@ -496,2 +577,4 @@ | ||
``` | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/scrollTo.js" target="_blank">Source code</a> | ||
* * * | ||
### setCookie | ||
@@ -520,5 +603,7 @@ | ||
``` | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/setCookie.js" target="_blank">Source code</a> | ||
* * * | ||
### setQuery | ||
Method to sum two numbers. | ||
Set query to url. | ||
@@ -539,4 +624,14 @@ #### Since | ||
```JS | ||
setQuery({ test: 'value' }) // => /?test=value setQuery({ test: ['12', '34'] }) // => /?test=12&test=34 // https://github.com/?test=value&field=test setQuery({ test: 'field' }, true) // => https://github.com/?test=value&test=field&field=test | ||
setQuery({ test: 'value' }) | ||
// => /?test=value | ||
setQuery({ test: ['12', '34'] }) | ||
// => /?test=12&test=34 | ||
// https://github.com/?test=value&field=test | ||
setQuery({ test: 'field' }, true) | ||
// => https://github.com/?test=value&test=field&field=test | ||
``` | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/setQuery.js" target="_blank">Source code</a> | ||
* * * | ||
### uniq | ||
@@ -559,7 +654,8 @@ | ||
```JS | ||
uniq(['test', 'field', 'test']) // => ['test', 'field'] | ||
uniq(['test', 'field', 'test']) | ||
// => ['test', 'field'] | ||
``` | ||
<a href="https://github.com/BrooonS/chober/tree/master/lib/uniq.js" target="_blank">Source code</a> | ||
* * * | ||
--- | ||
© Valery Strelets |
@@ -12,2 +12,3 @@ import getType from './getType'; | ||
* // => true | ||
* | ||
* isArray({}) | ||
@@ -14,0 +15,0 @@ * // => false |
@@ -12,2 +12,3 @@ import getType from './getType'; | ||
* // => true | ||
* | ||
* isBoolean([]) | ||
@@ -14,0 +15,0 @@ * // => false |
@@ -12,2 +12,3 @@ import getType from './getType'; | ||
* // => true | ||
* | ||
* isNumber([]) | ||
@@ -14,0 +15,0 @@ * // => false |
@@ -12,2 +12,3 @@ import getType from './getType'; | ||
* // => true | ||
* | ||
* isObject(123) | ||
@@ -14,0 +15,0 @@ * // => false |
@@ -12,2 +12,3 @@ import getType from './getType'; | ||
* // => true | ||
* | ||
* isString([]) | ||
@@ -14,0 +15,0 @@ * // => false |
@@ -7,3 +7,3 @@ import getQuery from './getQuery'; | ||
/** | ||
* Method to sum two numbers. | ||
* Set query to url. | ||
* | ||
@@ -62,12 +62,18 @@ * @since 0.3.0 | ||
const newQueryString = Object.keys(newQueryObject) | ||
.map(key => (Array.isArray(newQueryObject[key]) | ||
? newQueryObject[key] | ||
.map(value => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`) | ||
.join('&') | ||
: `${encodeURIComponent(key)}=${encodeURIComponent(newQueryObject[key])}`)) | ||
.map((key) => { | ||
const fieldValue = key && newQueryObject[key] | ||
? `${encodeURIComponent(key)}=${encodeURIComponent(newQueryObject[key])}` | ||
: ''; | ||
return Array.isArray(newQueryObject[key]) | ||
? newQueryObject[key] | ||
.map(value => (value && key ? `${encodeURIComponent(key)}=${encodeURIComponent(value)}` : '')) | ||
.join('&') | ||
: fieldValue; | ||
}) | ||
.join('&'); | ||
window.history.pushState('', '', `?${decodeURIComponent(newQueryString)}`); | ||
window.history.pushState('', '', newQueryString ? `?${decodeURIComponent(newQueryString)}` : ''); | ||
} | ||
export default setQuery; |
{ | ||
"name": "chober", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Chober.js - is a collection of methods that are used by programmers every day. We decided to put all the methods together so as not to copy them from project to project.", | ||
@@ -5,0 +5,0 @@ "main": "dist/chober.js", |
@@ -12,3 +12,3 @@ # Chober.js | ||
Install with [npm](https://npmjs.com/). | ||
Install with [npm](https://www.npmjs.com/package/chober). | ||
@@ -32,3 +32,3 @@ ```sh | ||
<!-- With version --> | ||
<script src="https://cdn.jsdelivr.net/npm/chober@1.0.0/dist/chober.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/chober@1.0.1/dist/chober.min.js"></script> | ||
``` | ||
@@ -35,0 +35,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
208884
1724