-
Notifications
You must be signed in to change notification settings - Fork 115
Statistic Module added #243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d7d95a2
Statistic Module added
adcd925
Error Fixed
063e7bd
Sum function dependency added and whitespaces issuse resolved
f637c05
Issue in statistics test js fixed
bdd4339
Underscore base package chnages
2239320
Merge branch 'master' of https://github.com/kpkalwa/underscore-contri…
2a76ba2
Docs added
c3aea80
Docs added and Changes made as suggested
72a910b
Changes made as suggested
acc73da
Bump ws from 7.3.1 to 7.4.6
dependabot[bot] a2c97bf
Bump path-parse from 1.0.6 to 1.0.7
dependabot[bot] d83d48b
Docs added
009a8cd
Docs added and Changes made as suggested
b130a04
Changes made as suggested
9962331
Merge branch 'statistics' of https://github.com/kpkalwa/underscore-co…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import identity from './identity.js'; | ||
| import isFunction from './isFunction.js'; | ||
| import isObject from './isObject.js'; | ||
| import isArray from './isArray.js'; | ||
| import matcher from './matcher.js'; | ||
| import property from './property.js'; | ||
| import optimizeCb from './_optimizeCb.js'; | ||
|
|
||
| // An internal function to generate callbacks that can be applied to each | ||
| // element in a collection, returning the desired result — either `_.identity`, | ||
| // an arbitrary callback, a property matcher, or a property accessor. | ||
| export default function baseIteratee(value, context, argCount) { | ||
| if (value == null) return identity; | ||
| if (isFunction(value)) return optimizeCb(value, context, argCount); | ||
| if (isObject(value) && !isArray(value)) return matcher(value); | ||
| return property(value); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import _ from './underscore.js'; | ||
| import baseIteratee from './_baseIteratee.js'; | ||
| import iteratee from './iteratee.js'; | ||
|
|
||
| // The function we call internally to generate a callback. It invokes | ||
| // `_.iteratee` if overridden, otherwise `baseIteratee`. | ||
| export default function cb(value, context, argCount) { | ||
| if (_.iteratee !== iteratee) return _.iteratee(value, context); | ||
| return baseIteratee(value, context, argCount); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { nonEnumerableProps, ObjProto } from './_setup.js'; | ||
| import isFunction from './isFunction.js'; | ||
| import has from './_has.js'; | ||
|
|
||
| // Internal helper to create a simple lookup structure. | ||
| // `collectNonEnumProps` used to depend on `_.contains`, but this led to | ||
| // circular imports. `emulatedSet` is a one-off solution that only works for | ||
| // arrays of strings. | ||
| function emulatedSet(keys) { | ||
| var hash = {}; | ||
| for (var l = keys.length, i = 0; i < l; ++i) hash[keys[i]] = true; | ||
| return { | ||
| contains: function(key) { return hash[key]; }, | ||
| push: function(key) { | ||
| hash[key] = true; | ||
| return keys.push(key); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| // Internal helper. Checks `keys` for the presence of keys in IE < 9 that won't | ||
| // be iterated by `for key in ...` and thus missed. Extends `keys` in place if | ||
| // needed. | ||
| export default function collectNonEnumProps(obj, keys) { | ||
| keys = emulatedSet(keys); | ||
| var nonEnumIdx = nonEnumerableProps.length; | ||
| var constructor = obj.constructor; | ||
| var proto = isFunction(constructor) && constructor.prototype || ObjProto; | ||
|
|
||
| // Constructor is a special case. | ||
| var prop = 'constructor'; | ||
| if (has(obj, prop) && !keys.contains(prop)) keys.push(prop); | ||
|
|
||
| while (nonEnumIdx--) { | ||
| prop = nonEnumerableProps[nonEnumIdx]; | ||
| if (prop in obj && obj[prop] !== proto[prop] && !keys.contains(prop)) { | ||
| keys.push(prop); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // An internal function for creating assigner functions. | ||
| export default function createAssigner(keysFunc, defaults) { | ||
| return function(obj) { | ||
| var length = arguments.length; | ||
| if (defaults) obj = Object(obj); | ||
| if (length < 2 || obj == null) return obj; | ||
| for (var index = 1; index < length; index++) { | ||
| var source = arguments[index], | ||
| keys = keysFunc(source), | ||
| l = keys.length; | ||
| for (var i = 0; i < l; i++) { | ||
| var key = keys[i]; | ||
| if (!defaults || obj[key] === void 0) obj[key] = source[key]; | ||
| } | ||
| } | ||
| return obj; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { MAX_ARRAY_INDEX } from './_setup.js'; | ||
|
|
||
| // Common internal logic for `isArrayLike` and `isBufferLike`. | ||
| export default function createSizePropertyCheck(getSizeProperty) { | ||
| return function(collection) { | ||
| var sizeProperty = getSizeProperty(collection); | ||
| return typeof sizeProperty == 'number' && sizeProperty >= 0 && sizeProperty <= MAX_ARRAY_INDEX; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // Internal function to obtain a nested property in `obj` along `path`. | ||
| export default function deepGet(obj, path) { | ||
| var length = path.length; | ||
| for (var i = 0; i < length; i++) { | ||
| if (obj == null) return void 0; | ||
| obj = obj[path[i]]; | ||
| } | ||
| return length ? obj : void 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| import shallowProperty from './_shallowProperty.js'; | ||
|
|
||
| // Internal helper to obtain the `length` property of an object. | ||
| export default shallowProperty('length'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import cb from './_cb.js'; | ||
| import each from './each.js'; | ||
|
|
||
| // An internal function used for aggregate "group by" operations. | ||
| export default function group(behavior, partition) { | ||
| return function(obj, iteratee, context) { | ||
| var result = partition ? [[], []] : {}; | ||
| iteratee = cb(iteratee, context); | ||
| each(obj, function(value, index) { | ||
| var key = iteratee(value, index, obj); | ||
| behavior(result, value, key); | ||
| }); | ||
| return result; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { hasOwnProperty } from './_setup.js'; | ||
|
|
||
| // Internal function to check whether `key` is an own property name of `obj`. | ||
| export default function has(obj, key) { | ||
| return obj != null && hasOwnProperty.call(obj, key); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import createSizePropertyCheck from './_createSizePropertyCheck.js'; | ||
| import getLength from './_getLength.js'; | ||
|
|
||
| // Internal helper for collection methods to determine whether a collection | ||
| // should be iterated as an array or as an object. | ||
| // Related: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength | ||
| // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094 | ||
| export default createSizePropertyCheck(getLength); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Internal function that returns an efficient (for current engines) version | ||
| // of the passed-in callback, to be repeatedly applied in other Underscore | ||
| // functions. | ||
| export default function optimizeCb(func, context, argCount) { | ||
| if (context === void 0) return func; | ||
| switch (argCount == null ? 3 : argCount) { | ||
| case 1: return function(value) { | ||
| return func.call(context, value); | ||
| }; | ||
| // The 2-argument case is omitted because we’re not using it. | ||
| case 3: return function(value, index, collection) { | ||
| return func.call(context, value, index, collection); | ||
| }; | ||
| case 4: return function(accumulator, value, index, collection) { | ||
| return func.call(context, accumulator, value, index, collection); | ||
| }; | ||
| } | ||
| return function() { | ||
| return func.apply(context, arguments); | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // Current version. | ||
| export var VERSION = '1.13.0'; | ||
|
|
||
| // Establish the root object, `window` (`self`) in the browser, `global` | ||
| // on the server, or `this` in some virtual machines. We use `self` | ||
| // instead of `window` for `WebWorker` support. | ||
| export var root = typeof self == 'object' && self.self === self && self || | ||
| typeof global == 'object' && global.global === global && global || | ||
| Function('return this')() || | ||
| {}; | ||
|
|
||
| // Save bytes in the minified (but not gzipped) version: | ||
| export var ArrayProto = Array.prototype, ObjProto = Object.prototype; | ||
| export var SymbolProto = typeof Symbol !== 'undefined' ? Symbol.prototype : null; | ||
|
|
||
| // Create quick reference variables for speed access to core prototypes. | ||
| export var push = ArrayProto.push, | ||
| slice = ArrayProto.slice, | ||
| toString = ObjProto.toString, | ||
| hasOwnProperty = ObjProto.hasOwnProperty; | ||
|
|
||
| // Modern feature detection. | ||
| export var supportsArrayBuffer = typeof ArrayBuffer !== 'undefined', | ||
| supportsDataView = typeof DataView !== 'undefined'; | ||
|
|
||
| // All **ECMAScript 5+** native function implementations that we hope to use | ||
| // are declared here. | ||
| export var nativeIsArray = Array.isArray, | ||
| nativeKeys = Object.keys, | ||
| nativeCreate = Object.create, | ||
| nativeIsView = supportsArrayBuffer && ArrayBuffer.isView; | ||
|
|
||
| // Create references to these builtin functions because we override them. | ||
| export var _isNaN = isNaN, | ||
| _isFinite = isFinite; | ||
|
|
||
| // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed. | ||
| export var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString'); | ||
| export var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString', | ||
| 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; | ||
|
|
||
| // The largest integer that can be represented exactly. | ||
| export var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| // Internal helper to generate a function to obtain property `key` from `obj`. | ||
| export default function shallowProperty(key) { | ||
| return function(obj) { | ||
| return obj == null ? void 0 : obj[key]; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { toString } from './_setup.js'; | ||
|
|
||
| // Internal function for creating a `toString`-based type tester. | ||
| export default function tagTester(name) { | ||
| var tag = '[object ' + name + ']'; | ||
| return function(obj) { | ||
| return toString.call(obj) === tag; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import _ from './underscore.js'; | ||
| import './toPath.js'; | ||
|
|
||
| // Internal wrapper for `_.toPath` to enable minification. | ||
| // Similar to `cb` for `_.iteratee`. | ||
| export default function toPath(path) { | ||
| return _.toPath(path); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import optimizeCb from './_optimizeCb.js'; | ||
| import isArrayLike from './_isArrayLike.js'; | ||
| import keys from './keys.js'; | ||
|
|
||
| // The cornerstone for collection functions, an `each` | ||
| // implementation, aka `forEach`. | ||
| // Handles raw objects in addition to array-likes. Treats all | ||
| // sparse array-likes as if they were dense. | ||
| export default function each(obj, iteratee, context) { | ||
| iteratee = optimizeCb(iteratee, context); | ||
| var i, length; | ||
| if (isArrayLike(obj)) { | ||
| for (i = 0, length = obj.length; i < length; i++) { | ||
| iteratee(obj[i], i, obj); | ||
| } | ||
| } else { | ||
| var _keys = keys(obj); | ||
| for (i = 0, length = _keys.length; i < length; i++) { | ||
| iteratee(obj[_keys[i]], _keys[i], obj); | ||
| } | ||
| } | ||
| return obj; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import createAssigner from './_createAssigner.js'; | ||
| import keys from './keys.js'; | ||
|
|
||
| // Assigns a given object with all the own properties in the passed-in | ||
| // object(s). | ||
| // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) | ||
| export default createAssigner(keys); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import initial from './initial.js'; | ||
|
|
||
| // Get the first element of an array. Passing **n** will return the first N | ||
| // values in the array. The **guard** check allows it to work with `_.map`. | ||
| export default function first(array, n, guard) { | ||
| if (array == null || array.length < 1) return n == null || guard ? void 0 : []; | ||
| if (n == null || guard) return array[0]; | ||
| return initial(array, array.length - n); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import group from './_group.js'; | ||
| import has from './_has.js'; | ||
|
|
||
| // Groups the object's values by a criterion. Pass either a string attribute | ||
| // to group by, or a function that returns the criterion. | ||
| export default group(function(result, value, key) { | ||
| if (has(result, key)) result[key].push(value); else result[key] = [value]; | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| // Keep the identity function around for default iteratees. | ||
| export default function identity(value) { | ||
| return value; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| //Statistical Function | ||
| export { default as sum } from './sum.js'; | ||
| export { default as mean } from './mean.js'; | ||
| export { default as median } from './median.js'; | ||
| export { default as standardDeviation } from './standardDeviation.js'; | ||
| export { default as variance } from './variance.js'; | ||
| export { default as mode } from './mode.js'; | ||
| export { default as standardError } from './standardError.js'; | ||
| export { default as statRange } from './statRange.js'; | ||
| export { default as percentile } from './percentile.js'; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { slice } from './_setup.js'; | ||
|
|
||
| // Returns everything but the last entry of the array. Especially useful on | ||
| // the arguments object. Passing **n** will return all the values in | ||
| // the array, excluding the last N. | ||
| export default function initial(array, n, guard) { | ||
| return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n))); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import tagTester from './_tagTester.js'; | ||
| import has from './_has.js'; | ||
|
|
||
| var isArguments = tagTester('Arguments'); | ||
|
|
||
| // Define a fallback version of the method in browsers (ahem, IE < 9), where | ||
| // there isn't any inspectable "Arguments" type. | ||
| (function() { | ||
| if (!isArguments(arguments)) { | ||
| isArguments = function(obj) { | ||
| return has(obj, 'callee'); | ||
| }; | ||
| } | ||
| }()); | ||
|
|
||
| export default isArguments; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { nativeIsArray } from './_setup.js'; | ||
| import tagTester from './_tagTester.js'; | ||
|
|
||
| // Is a given value an array? | ||
| // Delegates to ECMA5's native `Array.isArray`. | ||
| export default nativeIsArray || tagTester('Array'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import getLength from './_getLength.js'; | ||
| import isArray from './isArray.js'; | ||
| import isString from './isString.js'; | ||
| import isArguments from './isArguments.js'; | ||
| import keys from './keys.js'; | ||
|
|
||
| // Is a given array, string, or object empty? | ||
| // An "empty" object has no enumerable own-properties. | ||
| export default function isEmpty(obj) { | ||
| if (obj == null) return true; | ||
| // Skip the more expensive `toString`-based type checks if `obj` has no | ||
| // `.length`. | ||
| var length = getLength(obj); | ||
| if (typeof length == 'number' && ( | ||
| isArray(obj) || isString(obj) || isArguments(obj) | ||
| )) return length === 0; | ||
| return getLength(keys(obj)) === 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import tagTester from './_tagTester.js'; | ||
| import { root } from './_setup.js'; | ||
|
|
||
| var isFunction = tagTester('Function'); | ||
|
|
||
| // Optimize `isFunction` if appropriate. Work around some `typeof` bugs in old | ||
| // v8, IE 11 (#1621), Safari 8 (#1929), and PhantomJS (#2236). | ||
| var nodelist = root.document && root.document.childNodes; | ||
| if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist != 'function') { | ||
| isFunction = function(obj) { | ||
| return typeof obj == 'function' || false; | ||
| }; | ||
| } | ||
|
|
||
| export default isFunction; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import keys from './keys.js'; | ||
|
|
||
| // Returns whether an object has a given set of `key:value` pairs. | ||
| export default function isMatch(object, attrs) { | ||
| var _keys = keys(attrs), length = _keys.length; | ||
| if (object == null) return !length; | ||
| var obj = Object(object); | ||
| for (var i = 0; i < length; i++) { | ||
| var key = _keys[i]; | ||
| if (attrs[key] !== obj[key] || !(key in obj)) return false; | ||
| } | ||
| return true; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| // Is a given variable an object? | ||
| export default function isObject(obj) { | ||
| var type = typeof obj; | ||
| return type === 'function' || type === 'object' && !!obj; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import tagTester from './_tagTester.js'; | ||
|
|
||
| export default tagTester('String'); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.