├── .editorconfig ├── .github └── workflows │ └── test.yml ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── array.js ├── array ├── all.js ├── any.js ├── compact.js ├── dig.js ├── each.js ├── empty.js ├── equals.js ├── excludes.js ├── find.js ├── findIndex.js ├── first.js ├── flatten.js ├── groupBy.js ├── inGroupsOf.js ├── includes.js ├── last.js ├── max.js ├── maxBy.js ├── min.js ├── minBy.js ├── range.js ├── reject.js ├── select.js ├── smartExcludes.js ├── smartIncludes.js ├── sum.js ├── tap.js └── uniq.js ├── bower.json ├── dist ├── array.min.js ├── array │ ├── all.min.js │ ├── any.min.js │ ├── compact.min.js │ ├── dig.min.js │ ├── each.min.js │ ├── empty.min.js │ ├── equals.min.js │ ├── excludes.min.js │ ├── find.min.js │ ├── findIndex.min.js │ ├── first.min.js │ ├── flatten.min.js │ ├── groupBy.min.js │ ├── inGroupsOf.min.js │ ├── includes.min.js │ ├── last.min.js │ ├── max.min.js │ ├── maxBy.min.js │ ├── min.min.js │ ├── minBy.min.js │ ├── range.min.js │ ├── reject.min.js │ ├── select.min.js │ ├── smartExcludes.min.js │ ├── smartIncludes.min.js │ ├── sum.min.js │ ├── tap.min.js │ └── uniq.min.js ├── functions │ ├── equals.min.js │ ├── isBlank.min.js │ ├── simpleType.min.js │ └── warn.min.js ├── generic.min.js ├── generic │ ├── equals.min.js │ ├── isBlank.min.js │ ├── isPresent.min.js │ ├── presence.min.js │ ├── simpleType.min.js │ └── try.min.js ├── number.min.js ├── number │ ├── ceil.min.js │ ├── floor.min.js │ ├── isDecimal.min.js │ ├── isEven.min.js │ ├── isInteger.min.js │ ├── isOdd.min.js │ └── round.min.js ├── object.min.js ├── object │ ├── all.min.js │ ├── any.min.js │ ├── compact.min.js │ ├── dig.min.js │ ├── each.min.js │ ├── empty.min.js │ ├── equals.min.js │ ├── except.min.js │ ├── hasKey.min.js │ ├── hasValue.min.js │ ├── join.min.js │ ├── keys.min.js │ ├── merge.min.js │ ├── notEmpty.min.js │ ├── only.min.js │ ├── rearmed.min.js │ ├── reject.min.js │ ├── select.min.js │ └── values.min.js ├── rearmed.min.js ├── string.min.js └── string │ ├── capitalize.min.js │ ├── caseCmp.min.js │ ├── chars.min.js │ ├── downcase.min.js │ ├── empty.min.js │ ├── endsWith.min.js │ ├── excludes.min.js │ ├── gsub.min.js │ ├── includes.min.js │ ├── lstrip.min.js │ ├── reverse.min.js │ ├── rstrip.min.js │ ├── startsWith.min.js │ ├── strip.min.js │ ├── sub.min.js │ ├── titleize.min.js │ ├── toBool.min.js │ └── upcase.min.js ├── functions ├── equals.js ├── isBlank.js ├── simpleType.js └── warn.js ├── generic.js ├── generic ├── equals.js ├── isBlank.js ├── isPresent.js ├── presence.js ├── simpleType.js └── try.js ├── gulpfile.js ├── number.js ├── number ├── ceil.js ├── floor.js ├── isDecimal.js ├── isEven.js ├── isInteger.js ├── isOdd.js └── round.js ├── object.js ├── object ├── all.js ├── any.js ├── compact.js ├── dig.js ├── each.js ├── empty.js ├── equals.js ├── except.js ├── hasKey.js ├── hasValue.js ├── join.js ├── keys.js ├── merge.js ├── only.js ├── rearmed.js ├── reject.js ├── select.js └── values.js ├── package.json ├── rearmed.js ├── src ├── rearmed.js └── rearmed │ ├── array.js │ ├── array │ ├── all.js │ ├── any.js │ ├── compact.js │ ├── dig.js │ ├── each.js │ ├── empty.js │ ├── equals.js │ ├── excludes.js │ ├── find.js │ ├── findIndex.js │ ├── first.js │ ├── flatten.js │ ├── groupBy.js │ ├── inGroupsOf.js │ ├── includes.js │ ├── last.js │ ├── max.js │ ├── maxBy.js │ ├── min.js │ ├── minBy.js │ ├── range.js │ ├── reject.js │ ├── select.js │ ├── smartExcludes.js │ ├── smartIncludes.js │ ├── sum.js │ ├── tap.js │ └── uniq.js │ ├── functions │ ├── equals.js │ ├── isBlank.js │ ├── simpleType.js │ └── warn.js │ ├── generic.js │ ├── generic │ ├── equals.js │ ├── isBlank.js │ ├── isPresent.js │ ├── presence.js │ ├── simpleType.js │ └── try.js │ ├── number.js │ ├── number │ ├── ceil.js │ ├── floor.js │ ├── isDecimal.js │ ├── isEven.js │ ├── isInteger.js │ ├── isOdd.js │ └── round.js │ ├── object.js │ ├── object │ ├── all.js │ ├── any.js │ ├── compact.js │ ├── dig.js │ ├── each.js │ ├── empty.js │ ├── equals.js │ ├── except.js │ ├── hasKey.js │ ├── hasValue.js │ ├── join.js │ ├── keys.js │ ├── merge.js │ ├── only.js │ ├── rearmed.js │ ├── reject.js │ ├── select.js │ └── values.js │ ├── string.js │ └── string │ ├── capitalize.js │ ├── caseCmp.js │ ├── chars.js │ ├── downcase.js │ ├── empty.js │ ├── endsWith.js │ ├── excludes.js │ ├── gsub.js │ ├── includes.js │ ├── lstrip.js │ ├── reverse.js │ ├── rstrip.js │ ├── startsWith.js │ ├── strip.js │ ├── sub.js │ ├── titleize.js │ ├── toBool.js │ └── upcase.js ├── string.js ├── string ├── capitalize.js ├── caseCmp.js ├── chars.js ├── downcase.js ├── empty.js ├── endsWith.js ├── excludes.js ├── gsub.js ├── includes.js ├── lstrip.js ├── reverse.js ├── rstrip.js ├── startsWith.js ├── strip.js ├── sub.js ├── titleize.js ├── toBool.js └── upcase.js └── test ├── array.js ├── functions.js ├── generic.js ├── number.js ├── object.js └── string.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | 10 | # Change these settings to your own preference 11 | indent_style = space 12 | indent_size = 2 13 | 14 | # We recommend you to keep these unchanged 15 | end_of_line = lf 16 | charset = utf-8 17 | trim_trailing_whitespace = true 18 | insert_final_newline = true 19 | 20 | [*.md] 21 | trim_trailing_whitespace = false 22 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | on: 3 | push: 4 | branches: ['master'] 5 | pull_request: 6 | 7 | jobs: 8 | test: 9 | runs-on: ubuntu-latest 10 | strategy: 11 | fail-fast: false 12 | matrix: 13 | include: 14 | ### TEST MULTIPLE JS VERSIONS 15 | - js_version: "12" # Oldest testable version 16 | - js_version: "latest" 17 | 18 | steps: 19 | - uses: actions/checkout@v2 20 | 21 | - name: Install Javascript 22 | uses: actions/setup-node@v3 23 | with: 24 | node-version: "${{ matrix.js_version }}" 25 | 26 | - run: npm install 27 | 28 | - run: npm test 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | logs 2 | *.log 3 | pids 4 | *.pid 5 | *.seed 6 | lib-cov 7 | coverage 8 | .grunt 9 | .lock-wscript 10 | build/Release 11 | node_modules 12 | .DS_Store 13 | .idea 14 | out/ 15 | bower_components 16 | node_modules 17 | yarn.lock 18 | package-lock.json 19 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | sudo: false 3 | cache: yarn 4 | node_js: 5 | - "node" 6 | - "8" 7 | - "7" 8 | - "6" 9 | - "5" 10 | - "4" 11 | - "iojs" 12 | - "0.12" 13 | - "0.10" 14 | 15 | matrix: 16 | allow_failures: 17 | - node_js: "iojs" 18 | - node_js: "0.12" 19 | - node_js: "0.10" 20 | 21 | notifications: 22 | email: false 23 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | - `v2.0.1` - Sept 19 ,2017 4 | * Change default argument for `Array.compact` and `Object.compact` from `[null, undefined]` to `[null, undefined, '']` 5 | - `v2.0.0` - Sept 2, 2017 6 | * Make all Object patches much safer by moving them under `Object.prototype.rearmed()` and `Object.rearmed` method to fix issue #2 7 | * Add `Object#rearmed.add()` and `Object.rearmed.remove()` methods for adding or removing methods to rearmed objects 8 | * Remove Core section to be replaced with Generic section 9 | * Add Generic `isBlank`, `isPresent`, `presence`, `simpleType`, `try` 10 | * Add Array `range` and `tap` methods 11 | * Fix `Object#all` when called with no callback function. Now defaults to if all values are truthy. 12 | * Remove `Array#notEmpty`, `Object#notEmpty`, and `String#notEmpty` 13 | - `v1.0.0` - May 6, 2017 14 | * Allow `all` and `any` methods without a callback 15 | * Fix some method warnings 16 | * Restructure directories because you cant define a root folder in npm... gross. 17 | * Hookup to travis-ci 18 | - `v0.9.0` - February 1, 2017 19 | * First Release 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Weston Ganger 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /array/all.js: -------------------------------------------------------------------------------- 1 | (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o0){for(var f=[],s=0;st)&&(t=i)}return t},Object.defineProperty(Array.prototype,"max",{enumerable:!1})}()},{"./../functions/simpleType":2,"./../functions/warn":3}],2:[function(r,n,t){n.exports=function(r){var n=typeof r;return"number"==n?n="Number":"string"==n?n="String":"boolean"==n?n="Boolean":r&&r.constructor&&r.call&&r.apply?n="Function":null!=r&&"object"==n&&(n=Array.isArray(r)?"Array":"Object"),n}},{}],3:[function(r,n,t){n.exports=function(r,n,t){if(!r||!n)throw"incorrect number of arguments";console.warn("Rearmed-js Overriding "+r+(t?".":".prototype.")+n,". If this is a built-in browser method please report on Rearmed-js github issues.")}},{}]},{},[1]); -------------------------------------------------------------------------------- /dist/array/maxBy.min.js: -------------------------------------------------------------------------------- 1 | !function r(n,e,t){function o(u,a){if(!e[u]){if(!n[u]){var c="function"==typeof require&&require;if(!a&&c)return c(u,!0);if(i)return i(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var s=e[u]={exports:{}};n[u][0].call(s.exports,function(r){var e=n[u][1][r];return o(e||r)},s,s.exports,r,n,e,t)}return e[u].exports}for(var i="function"==typeof require&&require,u=0;ut)&&(e=u,t=a)}return e},Object.defineProperty(Array.prototype,"maxBy",{enumerable:!1})}()},{"./../functions/simpleType":2,"./../functions/warn":3}],2:[function(r,n,e){n.exports=function(r){var n=typeof r;return"number"==n?n="Number":"string"==n?n="String":"boolean"==n?n="Boolean":r&&r.constructor&&r.call&&r.apply?n="Function":null!=r&&"object"==n&&(n=Array.isArray(r)?"Array":"Object"),n}},{}],3:[function(r,n,e){n.exports=function(r,n,e){if(!r||!n)throw"incorrect number of arguments";console.warn("Rearmed-js Overriding "+r+(e?".":".prototype.")+n,". If this is a built-in browser method please report on Rearmed-js github issues.")}},{}]},{},[1]); -------------------------------------------------------------------------------- /dist/array/min.min.js: -------------------------------------------------------------------------------- 1 | !function r(n,t,e){function o(u,a){if(!t[u]){if(!n[u]){var s="function"==typeof require&&require;if(!a&&s)return s(u,!0);if(i)return i(u,!0);var c=new Error("Cannot find module '"+u+"'");throw c.code="MODULE_NOT_FOUND",c}var f=t[u]={exports:{}};n[u][0].call(f.exports,function(r){var t=n[u][1][r];return o(t||r)},f,f.exports,r,n,t,e)}return t[u].exports}for(var i="function"==typeof require&&require,u=0;u0?e>=r:e<=r;)t.push(r),r+=n;return t}}()},{"./../functions/warn":2}],2:[function(r,e,n){e.exports=function(r,e,n){if(!r||!e)throw"incorrect number of arguments";console.warn("Rearmed-js Overriding "+r+(n?".":".prototype.")+e,". If this is a built-in browser method please report on Rearmed-js github issues.")}},{}]},{},[1]); -------------------------------------------------------------------------------- /dist/array/reject.min.js: -------------------------------------------------------------------------------- 1 | !function r(e,t,n){function o(u,f){if(!t[u]){if(!e[u]){var c="function"==typeof require&&require;if(!f&&c)return c(u,!0);if(i)return i(u,!0);var a=new Error("Cannot find module '"+u+"'");throw a.code="MODULE_NOT_FOUND",a}var s=t[u]={exports:{}};e[u][0].call(s.exports,function(r){var t=e[u][1][r];return o(t||r)},s,s.exports,r,e,t,n)}return t[u].exports}for(var i="function"==typeof require&&require,u=0;u1){var n=Array.prototype.slice.call(arguments);n.shift()}e=e.apply(this,n)}return!(!e&&0!==e&&""!==e)&&e}return!1},Object.defineProperty(Object.prototype,"try",{enumerable:!1})}}()},{"./../functions/simpleType":1}]},{},[2]); -------------------------------------------------------------------------------- /dist/number/ceil.min.js: -------------------------------------------------------------------------------- 1 | !function r(e,t,n){function o(u,c){if(!t[u]){if(!e[u]){var f="function"==typeof require&&require;if(!c&&f)return f(u,!0);if(i)return i(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var a=t[u]={exports:{}};e[u][0].call(a.exports,function(r){var t=e[u][1][r];return o(t||r)},a,a.exports,r,e,t,n)}return t[u].exports}for(var i="function"==typeof require&&require,u=0;u0}})}()},{}]},{},[1]); -------------------------------------------------------------------------------- /dist/object/only.min.js: -------------------------------------------------------------------------------- 1 | !function r(e,n,t){function i(u,f){if(!n[u]){if(!e[u]){var a="function"==typeof require&&require;if(!f&&a)return a(u,!0);if(o)return o(u,!0);var c=new Error("Cannot find module '"+u+"'");throw c.code="MODULE_NOT_FOUND",c}var s=n[u]={exports:{}};e[u][0].call(s.exports,function(r){var n=e[u][1][r];return i(n||r)},s,s.exports,r,e,n,t)}return n[u].exports}for(var o="function"==typeof require&&require,u=0;u 0){ 27 | var group = []; 28 | for(var j=0;j max){ 18 | max = val; 19 | } 20 | } 21 | return max; 22 | }; 23 | 24 | Object.defineProperty(Array.prototype, "max", {enumerable: false}); 25 | }(this)); 26 | -------------------------------------------------------------------------------- /src/rearmed/array/maxBy.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | "use strict"; 3 | 4 | var simpleType = require('./../functions/simpleType'); 5 | 6 | var warn = require('./../functions/warn'); 7 | if(Array.prototype.maxBy){ 8 | warn('Array', 'maxBy'); 9 | } 10 | 11 | Array.prototype.maxBy = function(cb){ 12 | var current, max; 13 | var hasCallback = simpleType(cb) == 'Function'; 14 | for(var i=0;i max){ 19 | current = item; 20 | max = val; 21 | } 22 | } 23 | return current; 24 | }; 25 | 26 | Object.defineProperty(Array.prototype, "maxBy", {enumerable: false}); 27 | }(this)); 28 | -------------------------------------------------------------------------------- /src/rearmed/array/min.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | "use strict"; 3 | 4 | var simpleType = require('./../functions/simpleType'); 5 | 6 | var warn = require('./../functions/warn'); 7 | if(Array.prototype.min){ 8 | warn('Array', 'min'); 9 | } 10 | 11 | Array.prototype.min = function(cb){ 12 | var min; 13 | var hasCallback = simpleType(cb) == 'Function'; 14 | for(var i=0;i 0 ? end >= start : end <= start){ 27 | range.push(start); 28 | start += step; 29 | } 30 | 31 | return range; 32 | }; 33 | }(this)); 34 | -------------------------------------------------------------------------------- /src/rearmed/array/reject.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | "use strict"; 3 | 4 | var warn = require('./../functions/warn'); 5 | if(Array.prototype.reject){ 6 | warn('Array', 'reject'); 7 | } 8 | 9 | Array.prototype.reject = function(cb){ 10 | return this.filter(function(x, i){ 11 | return !cb(x,i); 12 | }); 13 | }; 14 | 15 | Object.defineProperty(Array.prototype, "reject", {enumerable: false}); 16 | }(this)); 17 | -------------------------------------------------------------------------------- /src/rearmed/array/select.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | "use strict"; 3 | 4 | var warn = require('./../functions/warn'); 5 | if(Array.prototype.select){ 6 | warn('Array', 'select'); 7 | } 8 | 9 | Array.prototype.select = function(cb){ 10 | return this.filter(cb); 11 | }; 12 | 13 | Object.defineProperty(Array.prototype, "select", {enumerable: false}); 14 | }(this)); 15 | -------------------------------------------------------------------------------- /src/rearmed/array/smartExcludes.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | "use strict"; 3 | 4 | var equals = require('./../functions/equals'); 5 | 6 | var warn = require('./../functions/warn'); 7 | if(Array.prototype.smartExcludes){ 8 | warn('Array', 'smartExcludes'); 9 | } 10 | 11 | Array.prototype.smartExcludes = function(x, fromIndex){ 12 | var fromIndex = fromIndex || 0; 13 | var bool = true; 14 | for(var i=fromIndex;i 1){ 12 | var args = Array.prototype.slice.call(arguments); 13 | args.shift(); 14 | } 15 | val = val.apply(this, args); 16 | } 17 | return (val || val === 0 || val === '') ? val : false; 18 | } 19 | return false; 20 | }; 21 | 22 | Object.defineProperty(Object.prototype, "try", {enumerable: false}); 23 | } 24 | }(this)); 25 | -------------------------------------------------------------------------------- /src/rearmed/number.js: -------------------------------------------------------------------------------- 1 | require('./number/ceil'); 2 | require('./number/floor'); 3 | require('./number/isDecimal'); 4 | require('./number/isEven'); 5 | require('./number/isInteger'); 6 | require('./number/isOdd'); 7 | require('./number/round'); 8 | -------------------------------------------------------------------------------- /src/rearmed/number/ceil.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | "use strict"; 3 | 4 | var warn = require('./../functions/warn'); 5 | if(Number.prototype.ceil){ 6 | warn('Number', 'ceil'); 7 | } 8 | 9 | Number.prototype.ceil = function(){ 10 | return Math.ceil(this); 11 | }; 12 | 13 | Object.defineProperty(Number.prototype, "ceil", {enumerable: false}); 14 | }(this)); 15 | -------------------------------------------------------------------------------- /src/rearmed/number/floor.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | "use strict"; 3 | 4 | var warn = require('./../functions/warn'); 5 | if(Number.prototype.floor){ 6 | warn('Number', 'floor'); 7 | } 8 | 9 | Number.prototype.floor = function(){ 10 | return Math.floor(this); 11 | }; 12 | 13 | Object.defineProperty(Number.prototype, "floor", {enumerable: false}); 14 | }(this)); 15 | -------------------------------------------------------------------------------- /src/rearmed/number/isDecimal.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | "use strict"; 3 | 4 | var warn = require('./../functions/warn'); 5 | if(Number.prototype.isDecimal){ 6 | warn('Number', 'isDecimal'); 7 | } 8 | 9 | Number.prototype.isDecimal = function(){ 10 | if(Number.isInteger){ 11 | return !Number.isInteger(this); 12 | }else{ 13 | return isFinite(this) && Math.floor(this) !== this; 14 | } 15 | } 16 | 17 | Object.defineProperty(Number.prototype, "isDecimal", {enumerable: false}); 18 | }(this)); 19 | -------------------------------------------------------------------------------- /src/rearmed/number/isEven.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | "use strict"; 3 | 4 | var warn = require('./../functions/warn'); 5 | if(Number.prototype.isEven){ 6 | warn('Number', 'isEven'); 7 | } 8 | 9 | Number.prototype.isEven = function(){ 10 | return isFinite(this) && this % 2 === 0; 11 | }; 12 | 13 | Object.defineProperty(Number.prototype, "isEven", {enumerable: false}); 14 | }(this)); 15 | -------------------------------------------------------------------------------- /src/rearmed/number/isInteger.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | "use strict"; 3 | 4 | var warn = require('./../functions/warn'); 5 | if(Number.prototype.isInteger){ 6 | warn('Number', 'isInteger'); 7 | } 8 | 9 | Number.prototype.isInteger = function(){ 10 | if(Number.isInteger){ 11 | return Number.isInteger(this); 12 | }else{ 13 | return isFinite(this) && Math.floor(this) === this; 14 | } 15 | }; 16 | 17 | Object.defineProperty(Number.prototype, "isInteger", {enumerable: false}); 18 | }(this)); 19 | -------------------------------------------------------------------------------- /src/rearmed/number/isOdd.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | "use strict"; 3 | 4 | var warn = require('./../functions/warn'); 5 | if(Number.prototype.isOdd){ 6 | warn('Number', 'isOdd'); 7 | } 8 | 9 | Number.prototype.isOdd = function(){ 10 | return isFinite(this) && Math.abs(this % 2) === 1; 11 | }; 12 | 13 | Object.defineProperty(Number.prototype, "isOdd", {enumerable: false}); 14 | }(this)); 15 | -------------------------------------------------------------------------------- /src/rearmed/number/round.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | "use strict"; 3 | 4 | var warn = require('./../functions/warn'); 5 | if(Number.prototype.round){ 6 | warn('Number', 'round'); 7 | } 8 | 9 | Number.prototype.round = function(){ 10 | return Math.round(this); 11 | }; 12 | 13 | Object.defineProperty(Number.prototype, "round", {enumerable: false}); 14 | }(this)); 15 | -------------------------------------------------------------------------------- /src/rearmed/object.js: -------------------------------------------------------------------------------- 1 | require('./object/rearmed'); 2 | 3 | require('./object/all'); 4 | require('./object/any'); 5 | require('./object/compact'); 6 | require('./object/dig'); 7 | require('./object/each'); 8 | require('./object/empty'); 9 | require('./object/equals'); 10 | require('./object/except'); 11 | require('./object/hasKey'); 12 | require('./object/hasValue'); 13 | require('./object/join'); 14 | require('./object/keys'); 15 | require('./object/merge'); 16 | require('./object/only'); 17 | require('./object/reject'); 18 | require('./object/select'); 19 | require('./object/values'); 20 | -------------------------------------------------------------------------------- /src/rearmed/object/all.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | "use strict"; 3 | 4 | Object.rearmed.add({ 5 | all: function(cb){ 6 | var bool = true; 7 | 8 | if(!cb){ 9 | cb = function(k,v){ 10 | return !!v; 11 | } 12 | } 13 | 14 | for(var k in this){ 15 | if(!cb(k, this[k])){ 16 | bool = false; 17 | break; 18 | } 19 | } 20 | 21 | return bool; 22 | } 23 | }); 24 | }(this)); 25 | -------------------------------------------------------------------------------- /src/rearmed/object/any.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | "use strict"; 3 | 4 | Object.rearmed.add({ 5 | any: function(cb){ 6 | var bool = false; 7 | 8 | if(!cb){ 9 | cb = function(){ 10 | return true; 11 | } 12 | } 13 | 14 | for(var k in this){ 15 | if(cb(k, this[k])){ 16 | bool = true; 17 | break; 18 | } 19 | } 20 | return bool; 21 | } 22 | }); 23 | }(this)); 24 | -------------------------------------------------------------------------------- /src/rearmed/object/compact.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | "use strict"; 3 | 4 | Object.rearmed.add({ 5 | compact: function(bad){ 6 | var bad; 7 | if(arguments.length === 0){ 8 | bad = [null, undefined, '']; 9 | }else if(arguments.length === 1){ 10 | if(Array.isArray(arguments[0])){ 11 | bad = arguments[0]; 12 | }else{ 13 | bad = [arguments[0]]; 14 | } 15 | }else{ 16 | bad = arguments; 17 | } 18 | 19 | var obj = {}; 20 | 21 | for(var k in this){ 22 | var val = this[k]; 23 | var bool = true; 24 | for(var i=0;i