nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: sindresorhus/ow
Pull request #216 (2021-07-09 01:44:42)

Remove unnecessary stack reference for `ow.array.ofType`
- Remove unnecessary stack reference for `ow.array.ofType` and refine the error message.
- In the [last PR](https://github.com/sindresorhus/ow/pull/214), I missed the case for an array.


Patch:
diff --git a/source/index.ts b/source/index.ts
index cbd9bcf..2e94e34 100644
--- a/source/index.ts
+++ b/source/index.ts
@@ -81,7 +81,7 @@ Object.defineProperties(ow, {
 	isValid: {
 		value: <T>(value: T, predicate: BasePredicate<T>): boolean => {
 			try {
-				ow(value, predicate);
+				test(value, '', predicate);
 				return true;
 			} catch {
 				return false;
diff --git a/source/predicates/array.ts b/source/predicates/array.ts
index 896a303..7f4e416 100644
--- a/source/predicates/array.ts
+++ b/source/predicates/array.ts
@@ -1,9 +1,9 @@
 import isEqual = require('lodash.isequal');
 import {BasePredicate} from './base-predicate';
 import {Predicate, PredicateOptions} from './predicate';
-import ow from '..';
 import {Shape} from './object';
 import {exact} from '../utils/match-shape';
+import ofType from '../utils/of-type';
 
 export class ArrayPredicate<T = unknown> extends Predicate<T[]> {
 	/**
@@ -142,23 +142,10 @@ export class ArrayPredicate<T = unknown> extends Predicate<T[]> {
 	```
 	*/
 	ofType<U extends T>(predicate: BasePredicate<U>): ArrayPredicate<U> {
-		let error: string;
-
 		// TODO [typescript@>=5] If higher-kinded types are supported natively by typescript, refactor `addValidator` to use them to avoid the usage of `any`. Otherwise, bump or remove this TODO.
 		return this.addValidator({
-			message: (_, label) => `(${label}) ${error}`,
-			validator: value => {
-				try {
-					for (const item of value) {
-						ow(item, predicate);
-					}
-
-					return true;
-				} catch (error_: unknown) {
-					error = (error_ as Error).message;
-					return false;
-				}
-			}
+			message: (_, label, error) => `(${label}) ${error}`,
+			validator: value => ofType(value, 'values', predicate)
 		}) as ArrayPredicate<any>;
 	}
 


Test patch:
diff --git a/test/array.ts b/test/array.ts
index bb71e57..3dee992 100644
--- a/test/array.ts
+++ b/test/array.ts
@@ -162,11 +162,19 @@ test('array.ofType', t => {
 
 	t.throws(() => {
 		ow(['foo', 'b'], ow.array.ofType(ow.string.minLength(3)));
-	}, '(array) Expected string to have a minimum length of `3`, got `b`');
+	}, '(array) Expected string values to have a minimum length of `3`, got `b`');
 
 	t.throws(() => {
 		ow(['foo', 'b'], 'foo', ow.array.ofType(ow.string.minLength(3)));
-	}, '(array `foo`) Expected string to have a minimum length of `3`, got `b`');
+	}, '(array `foo`) Expected string values to have a minimum length of `3`, got `b`');
+
+	t.throws(() => {
+		ow(['foo', 'bar'], 'foo', ow.array.ofType(ow.number));
+	}, '(array `foo`) Expected values to be of type `number` but received type `string`');
+
+	t.throws(() => {
+		ow([1, -1], 'foo', ow.array.ofType(ow.number.not.negative));
+	}, '(array `foo`) Expected number values to not be negative, got -1');
 });
 
 test('array.exactShape', t => {
Repository: sindresorhus/got
Pull request #2104 (2022-08-09 14:39:06)

Don't call beforeError hooks with HTTPError if !throwHttpErrors
Fixes https://github.com/sindresorhus/got/issues/2103


Patch:
diff --git a/documentation/3-streams.md b/documentation/3-streams.md
index 9070e43..5fe237c 100644
--- a/documentation/3-streams.md
+++ b/documentation/3-streams.md
@@ -239,6 +239,11 @@ To enable retrying when using streams, a retry handler must be attached.
 
 When this event is emitted, you should reset the stream you were writing to and prepare the body again.
 
+**Note:**
+> - [`HTTPError`s](./8-errors.md#httperror) cannot be retried if [`options.throwHttpErrors`](./2-options.md#throwhttperrors) is `false`.
+>   This is because stream data is saved to `error.response.body` and streams can be read only once.
+> - For the Promise API, there is no such limitation.
+
 #### `retryCount`
 
 **Type: `number`**
diff --git a/source/core/index.ts b/source/core/index.ts
index edb1246..4ead97a 100644
--- a/source/core/index.ts
+++ b/source/core/index.ts
@@ -797,6 +797,10 @@ export default class Request extends Duplex implements RequestEvents<Request> {
 			return;
 		}
 
+		// `HTTPError`s always have `error.response.body` defined.
+		// Therefore we cannot retry if `options.throwHttpErrors` is false.
+		// On the last retry, if `options.throwHttpErrors` is false, we would need to return the body,
+		// but that wouldn't be possible since the body would be already read in `error.response.body`.
 		if (options.isStream && options.throwHttpErrors && !isResponseOk(typedResponse)) {
 			this._beforeError(new HTTPError(typedResponse));
 			return;
@@ -1148,9 +1152,15 @@ export default class Request extends Duplex implements RequestEvents<Request> {
 
 	private async _error(error: RequestError): Promise<void> {
 		try {
-			for (const hook of this.options.hooks.beforeError) {
-				// eslint-disable-next-line no-await-in-loop
-				error = await hook(error);
+			if (error instanceof HTTPError && !this.options.throwHttpErrors) {
+				// This branch can be reached only when using the Promise API
+				// Skip calling the hooks on purpose.
+				// See https://github.com/sindresorhus/got/issues/2103
+			} else {
+				for (const hook of this.options.hooks.beforeError) {
+					// eslint-disable-next-line no-await-in-loop
+					error = await hook(error);
+				}
 			}
 		} catch (error_: any) {
 			error = new RequestError(error_.message, error_, this);


Test patch:
diff --git a/test/hooks.ts b/test/hooks.ts
index fab442a..2241137 100644
--- a/test/hooks.ts
+++ b/test/hooks.ts
@@ -1368,3 +1368,26 @@ test('does not throw on empty body when running afterResponse hooks', withServer
 		},
 	}));
 });
+
+test('does not call beforeError hooks on falsy throwHttpErrors', withServer, async (t, server, got) => {
+	server.get('/', (_request, response) => {
+		response.statusCode = 404;
+		response.end();
+	});
+
+	let called = false;
+
+	await got('', {
+		throwHttpErrors: false,
+		hooks: {
+			beforeError: [
+				error => {
+					called = true;
+					return error;
+				},
+			],
+		},
+	});
+
+	t.false(called);
+});
Repository: sindresorhus/is
Pull request #3 (2017-09-23 11:13:17)

Add `is.inRange()`

sudo-suhas: Destructuring isn't supported on node 4.
sindresorhus: Yes
sindresorhus: Let’s call it `inRange`. And let’s do the Math.min/max thing you suggested so the range parameters can be specified in any order and also be negative.
glhrmv: How's this?
brandon93s: Could also borrow from [sindresorhus/in-range](https://github.com/sindresorhus/in-range/blob/master/index.js). It allows start to be optional, with a default of 0.
sindresorhus: > Could also borrow from sindresorhus/in-range. It allows start to be optional, with a default of 0.

Good idea. I forgot I had that module. We could also support `is.inRange(5, 10)`. So the user can either use an array as range or a number as upper-bound. Thoughts?
brandon93s: I agree. The flexibility of supporting both inputs would be nice. 
glhrmv: How about now? 😃

Patch:
diff --git a/index.js b/index.js
index 78b4368..99caa9a 100644
--- a/index.js
+++ b/index.js
@@ -150,4 +150,12 @@ const typedArrayTypes = new Set([
 ]);
 is.typedArray = x => typedArrayTypes.has(getObjectType(x));
 
+is.inRange = (x, range) => {
+	if (is.number(range)) {
+		return (x >= Math.min(0, range)) && (x <= Math.max(range, 0));
+	}
+
+	return (is.array(range)) && (x >= Math.min.apply(Math, range)) && (x <= Math.max.apply(Math, range));
+};
+
 module.exports = is;
diff --git a/readme.md b/readme.md
index 45ade28..40e5d1b 100644
--- a/readme.md
+++ b/readme.md
@@ -121,6 +121,13 @@ Returns `true` for instances created by a ES2015 class.
 
 ##### .typedArray(value)
 
+##### .inRange(value, range)
+
+Check to see if the value is within a given range, for example `is.inRange(3, [0, 5])`.
+The range supplied can be an array of any size, though this will only check for
+the minimum and maximum values in it.
+
+If `range` is a number (e.g., `is.inRange(3, 10)`), it will be treated as a range of 0 to `range`.
 
 ## FAQ
 


Test patch:
diff --git a/test.js b/test.js
index 357aa55..6f5d6a6 100644
--- a/test.js
+++ b/test.js
@@ -305,3 +305,16 @@ test('is.typedArray', t => {
 	t.false(m.typedArray([]));
 	t.false(m.typedArray({}));
 });
+
+test('is.inRange', t => {
+	const x = 3;
+
+	t.true(m.inRange(x, [0, 5]));
+	t.true(m.inRange(x, [5, 0]));
+	t.true(m.inRange(x, [-5, 5]));
+	t.true(m.inRange(x, [5, -5]));
+	t.false(m.inRange(x, [4, 8]));
+
+	t.true(m.inRange(x, 10));
+	t.false(m.inRange(x, 2));
+});
Repository: sindresorhus/is
Pull request #16 (2017-10-05 15:35:19)

Add is.empty()
Added the `is.empty(value)` function as mentioned in #1.

gioragutt: @kodie nice PR, personally been waiting for this in my app. Couple of changes for readability and clean code, but it seems fine otherwise.
kodie: @gioragutt Fixing those right now!

Quick question, what should booleans return?

```js
is.empty(true);
is.empty(false);
```

?
gioragutt: @kodie not quite sure, I believe that `is.empty(boolean) === !boolean`, but that's a thought.

@sindresorhus your thought?
kodie: @gioragutt I've made the requested changes. I made it just return true if given a falsy value. So `true` will return false but `false`, `null`, and `undefined` will all return true.

Patch:
diff --git a/index.js b/index.js
index f7a16fd..37f27f6 100644
--- a/index.js
+++ b/index.js
@@ -163,4 +163,10 @@ is.inRange = (x, range) => {
 
 is.infinite = x => x === Infinity || x === -Infinity;
 
+const isEmptyStringOrArray = x => (is.string(x) || is.array(x)) && x.length === 0;
+const isEmptyObject = x => !is.map(x) && !is.set(x) && is.object(x) && Object.keys(x).length === 0;
+const isEmptyMapOrSet = x => (is.map(x) || is.set(x)) && x.size === 0;
+
+is.empty = x => !x || isEmptyStringOrArray(x) || isEmptyObject(x) || isEmptyMapOrSet(x);
+
 module.exports = is;
diff --git a/readme.md b/readme.md
index fab01c1..8c9a29e 100644
--- a/readme.md
+++ b/readme.md
@@ -150,6 +150,11 @@ is.inRange(3, 10);
 Check if `value` is `Infinity` or `-Infinity`.
 
 
+##### .empty(value)
+
+Returns `true` if `value` is falsy or an empty string, array, object, map, or set.
+
+
 ## FAQ
 
 ### Why yet another type checking module?


Test patch:
diff --git a/test.js b/test.js
index a2c4337..336bc45 100644
--- a/test.js
+++ b/test.js
@@ -373,3 +373,32 @@ test('is.inRange', t => {
 test('is.infinite', t => {
 	testType(t, 'infinite', ['number']);
 });
+
+test('is.empty', t => {
+	t.true(m.empty(null));
+	t.true(m.empty(undefined));
+
+	t.true(m.empty(false));
+	t.false(m.empty(true));
+
+	t.true(m.empty(''));
+	t.false(m.empty('🦄'));
+
+	t.true(m.empty([]));
+	t.false(m.empty(['🦄']));
+
+	t.true(m.empty({}));
+	t.false(m.empty({unicorn: '🦄'}));
+
+	const tempMap = new Map();
+	t.true(m.empty(tempMap));
+
+	tempMap.set('unicorn', '🦄');
+	t.false(m.empty(tempMap));
+
+	const tempSet = new Set();
+	t.true(m.empty(tempSet));
+
+	tempSet.add(1);
+	t.false(m.empty(tempSet));
+});
Repository: sindresorhus/is
Pull request #17 (2017-10-05 22:51:08)

Add link to is-blob

gioragutt: @sindresorhus looking at `is-blob`, it can be easily integrated into `is`, without adding it as a dependency
melvin0008: Thanks for pointing that out. It totally missed me
melvin0008: @gioragutt  I do agree is-blob can be integrated into is. Infact @sindresorhus included it in his list of ideas. Let me know if I should make a PR for it

Patch:
diff --git a/index.js b/index.js
index f7a16fd..37f27f6 100644
--- a/index.js
+++ b/index.js
@@ -163,4 +163,10 @@ is.inRange = (x, range) => {
 
 is.infinite = x => x === Infinity || x === -Infinity;
 
+const isEmptyStringOrArray = x => (is.string(x) || is.array(x)) && x.length === 0;
+const isEmptyObject = x => !is.map(x) && !is.set(x) && is.object(x) && Object.keys(x).length === 0;
+const isEmptyMapOrSet = x => (is.map(x) || is.set(x)) && x.size === 0;
+
+is.empty = x => !x || isEmptyStringOrArray(x) || isEmptyObject(x) || isEmptyMapOrSet(x);
+
 module.exports = is;
diff --git a/readme.md b/readme.md
index fab01c1..d3dc021 100644
--- a/readme.md
+++ b/readme.md
@@ -150,6 +150,11 @@ is.inRange(3, 10);
 Check if `value` is `Infinity` or `-Infinity`.
 
 
+##### .empty(value)
+
+Returns `true` if `value` is falsy or an empty string, array, object, map, or set.
+
+
 ## FAQ
 
 ### Why yet another type checking module?
@@ -177,6 +182,7 @@ The most common mistakes I noticed in these modules was using `instanceof` for t
 - [is-array-sorted](https://github.com/sindresorhus/is-array-sorted) - Check if an Array is sorted
 - [is-error-constructor](https://github.com/sindresorhus/is-error-constructor) - Check if a value is an error constructor
 - [is-empty-iterable](https://github.com/sindresorhus/is-empty-iterable) - Check if an Iterable is empty
+- [is-blob](https://github.com/sindresorhus/is-blob) - Check if a value is a Blob - File-like object of immutable, raw data
 
 
 ## Created by


Test patch:
diff --git a/test.js b/test.js
index a2c4337..336bc45 100644
--- a/test.js
+++ b/test.js
@@ -373,3 +373,32 @@ test('is.inRange', t => {
 test('is.infinite', t => {
 	testType(t, 'infinite', ['number']);
 });
+
+test('is.empty', t => {
+	t.true(m.empty(null));
+	t.true(m.empty(undefined));
+
+	t.true(m.empty(false));
+	t.false(m.empty(true));
+
+	t.true(m.empty(''));
+	t.false(m.empty('🦄'));
+
+	t.true(m.empty([]));
+	t.false(m.empty(['🦄']));
+
+	t.true(m.empty({}));
+	t.false(m.empty({unicorn: '🦄'}));
+
+	const tempMap = new Map();
+	t.true(m.empty(tempMap));
+
+	tempMap.set('unicorn', '🦄');
+	t.false(m.empty(tempMap));
+
+	const tempSet = new Set();
+	t.true(m.empty(tempSet));
+
+	tempSet.add(1);
+	t.false(m.empty(tempSet));
+});
Repository: sindresorhus/is
Pull request #21 (2017-10-17 01:28:02)

Add is.emptyOrWhitespace()

sindresorhus: Can you fix the merge conflict?
brandon93s: Conflicts resolved

Patch:
diff --git a/index.js b/index.js
index d5abf64..f5d76ce 100644
--- a/index.js
+++ b/index.js
@@ -183,11 +183,13 @@ const isAbsoluteMod2 = value => x => is.integer(x) && Math.abs(x % 2) === value;
 is.even = isAbsoluteMod2(0);
 is.odd = isAbsoluteMod2(1);
 
+const isWhiteSpaceString = x => is.string(x) && /\S/.test(x) === false;
 const isEmptyStringOrArray = x => (is.string(x) || is.array(x)) && x.length === 0;
 const isEmptyObject = x => !is.map(x) && !is.set(x) && is.object(x) && Object.keys(x).length === 0;
 const isEmptyMapOrSet = x => (is.map(x) || is.set(x)) && x.size === 0;
 
 is.empty = x => !x || isEmptyStringOrArray(x) || isEmptyObject(x) || isEmptyMapOrSet(x);
+is.emptyOrWhitespace = x => is.empty(x) || isWhiteSpaceString(x);
 
 const predicateOnArray = (method, predicate, values) => {
 	// `values` is the calling function's "arguments object".
diff --git a/readme.md b/readme.md
index 1760692..c1eae3f 100644
--- a/readme.md
+++ b/readme.md
@@ -182,6 +182,10 @@ Returns `true` if `value` is an odd integer.
 
 Returns `true` if `value` is falsy or an empty string, array, object, map, or set.
 
+##### .emptyOrWhitespace(value)
+
+Returns `true` if `is.empty(value)` or a string that is all whitespace.
+
 
 ##### .any(predicate, ...values)
 


Test patch:
diff --git a/test.js b/test.js
index 910f37a..31e6055 100644
--- a/test.js
+++ b/test.js
@@ -468,6 +468,13 @@ test('is.empty', t => {
 	t.false(m.empty(tempSet));
 });
 
+test('is.emptyOrWhitespace', t => {
+	t.true(m.emptyOrWhitespace(''));
+	t.true(m.emptyOrWhitespace('  '));
+	t.false(m.emptyOrWhitespace('🦄'));
+	t.false(m.emptyOrWhitespace('unicorn'));
+});
+
 test('is.any', t => {
 	t.true(m.any(m.string, {}, true, '🦄'));
 	t.true(m.any(m.object, false, {}, 'unicorns'));
Repository: sindresorhus/is
Pull request #22 (2017-10-17 01:28:44)

Add is.safeInteger()


Patch:
diff --git a/index.js b/index.js
index 0da91b3..e98bd94 100644
--- a/index.js
+++ b/index.js
@@ -124,6 +124,7 @@ const primitiveTypes = new Set([
 is.primitive = x => is.null(x) || primitiveTypes.has(typeof x);
 
 is.integer = Number.isInteger;
+is.safeInteger = Number.isSafeInteger;
 
 is.plainObject = x => {
 	// From: https://github.com/sindresorhus/is-plain-obj/blob/master/index.js
diff --git a/readme.md b/readme.md
index 9e565fb..3f3e20d 100644
--- a/readme.md
+++ b/readme.md
@@ -128,6 +128,11 @@ is.asyncFunction(() => {});
 JavaScript primitives are as follows: `null`, `undefined`, `string`, `number`, `boolean`, `symbol`.
 
 ##### .integer(value)
+
+##### .safeInteger(value)
+
+Returns `true` if `value` is a [safe integer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger).
+
 ##### .plainObject(value)
 
 An object is plain if it's created by either `{}`, `new Object()`, or `Object.create(null)`.


Test patch:
diff --git a/test.js b/test.js
index 0d62dce..d65a7a0 100644
--- a/test.js
+++ b/test.js
@@ -98,6 +98,10 @@ const types = new Map([
 		new Object() // eslint-disable-line no-new-object
 	]],
 	['integer', 6],
+	['safeInteger', [
+		Math.pow(2, 53) - 1,
+		-Math.pow(2, 53) + 1
+	]],
 	['domElement', [
 		'div',
 		'input',
@@ -160,7 +164,7 @@ test('is.string', t => {
 });
 
 test('is.number', t => {
-	testType(t, 'number', ['nan', 'integer', 'infinite']);
+	testType(t, 'number', ['nan', 'integer', 'safeInteger', 'infinite']);
 });
 
 test('is.boolean', t => {
@@ -312,10 +316,16 @@ test('is.primitive', t => {
 });
 
 test('is.integer', t => {
-	testType(t, 'integer', ['number']);
+	testType(t, 'integer', ['number', 'safeInteger']);
 	t.false(m.integer(1.4));
 });
 
+test('is.safeInteger', t => {
+	testType(t, 'safeInteger', ['number', 'integer']);
+	t.false(m.safeInteger(Math.pow(2, 53)));
+	t.false(m.safeInteger(-Math.pow(2, 53)));
+});
+
 test('is.plainObject', t => {
 	testType(t, 'plainObject', ['object', 'promise']);
 });
Repository: sindresorhus/is
Pull request #25 (2017-10-20 01:46:36)

Add `is.truthy()` and `is.falsy()`


Patch:
diff --git a/index.js b/index.js
index f5d76ce..5c5e656 100644
--- a/index.js
+++ b/index.js
@@ -111,6 +111,9 @@ is.float64Array = isObjectOfType('Float64Array');
 is.arrayBuffer = isObjectOfType('ArrayBuffer');
 is.sharedArrayBuffer = isObjectOfType('SharedArrayBuffer');
 
+is.truthy = x => !!x; // eslint-disable-line no-implicit-coercion
+is.falsy = x => !x;
+
 is.nan = Number.isNaN;
 is.nullOrUndefined = x => is.null(x) || is.undefined(x);
 
@@ -188,7 +191,7 @@ const isEmptyStringOrArray = x => (is.string(x) || is.array(x)) && x.length ===
 const isEmptyObject = x => !is.map(x) && !is.set(x) && is.object(x) && Object.keys(x).length === 0;
 const isEmptyMapOrSet = x => (is.map(x) || is.set(x)) && x.size === 0;
 
-is.empty = x => !x || isEmptyStringOrArray(x) || isEmptyObject(x) || isEmptyMapOrSet(x);
+is.empty = x => is.falsy(x) || isEmptyStringOrArray(x) || isEmptyObject(x) || isEmptyMapOrSet(x);
 is.emptyOrWhitespace = x => is.empty(x) || isWhiteSpaceString(x);
 
 const predicateOnArray = (method, predicate, values) => {
diff --git a/readme.md b/readme.md
index c1eae3f..51b18bf 100644
--- a/readme.md
+++ b/readme.md
@@ -121,6 +121,22 @@ is.asyncFunction(() => {});
 
 #### Miscellaneous
 
+##### .truthy(value)
+
+Returns `true` for all values that evaluate to true in a boolean context:
+
+```js
+is.truthy('🦄');
+//=> true
+
+is.truthy(undefined);
+//=> false
+```
+
+##### .falsy(value)
+
+Returns `true` if `value` is one of: `false`, `0`, `''`, `null`, `undefined`, `NaN`. 
+
 ##### .nan(value)
 ##### .nullOrUndefined(value)
 ##### .primitive(value)


Test patch:
diff --git a/test.js b/test.js
index 31e6055..f35eb08 100644
--- a/test.js
+++ b/test.js
@@ -289,6 +289,23 @@ test('is.dataView', t => {
 	testType(t, 'arrayBuffer');
 });
 
+test('is.truthy', t => {
+	t.true(m.truthy('unicorn'));
+	t.true(m.truthy('🦄'));
+	t.true(m.truthy(new Set()));
+	t.true(m.truthy(Symbol('🦄')));
+	t.true(m.truthy(true));
+});
+
+test('is.falsy', t => {
+	t.true(m.falsy(false));
+	t.true(m.falsy(0));
+	t.true(m.falsy(''));
+	t.true(m.falsy(null));
+	t.true(m.falsy(undefined));
+	t.true(m.falsy(NaN));
+});
+
 test('is.nan', t => {
 	testType(t, 'nan');
 });
Repository: sindresorhus/is
Pull request #26 (2017-10-22 22:07:42)

Add `is.arrayLike()`
Implements `is.arrayLike`.


Patch:
diff --git a/index.js b/index.js
index 5c5e656..ed9fed7 100644
--- a/index.js
+++ b/index.js
@@ -155,6 +155,9 @@ const typedArrayTypes = new Set([
 ]);
 is.typedArray = x => typedArrayTypes.has(getObjectType(x));
 
+const isValidLength = x => is.safeInteger(x) && x > -1;
+is.arrayLike = x => !is.nullOrUndefined(x) && !is.function(x) && isValidLength(x.length);
+
 is.inRange = (x, range) => {
 	if (is.number(range)) {
 		return x >= Math.min(0, range) && x <= Math.max(range, 0);
diff --git a/readme.md b/readme.md
index 51b18bf..20e9441 100644
--- a/readme.md
+++ b/readme.md
@@ -86,7 +86,7 @@ Returns `true` for any object that implements its own `.next()` and `.throw()` m
 
 ##### .asyncFunction(value)
 
-Returns `true` for any `async` function that can be called with the `await` operator. 
+Returns `true` for any `async` function that can be called with the `await` operator.
 
 ```js
 is.asyncFunction(async () => {});
@@ -135,7 +135,7 @@ is.truthy(undefined);
 
 ##### .falsy(value)
 
-Returns `true` if `value` is one of: `false`, `0`, `''`, `null`, `undefined`, `NaN`. 
+Returns `true` if `value` is one of: `false`, `0`, `''`, `null`, `undefined`, `NaN`.
 
 ##### .nan(value)
 ##### .nullOrUndefined(value)
@@ -160,6 +160,20 @@ Returns `true` for instances created by a ES2015 class.
 
 ##### .typedArray(value)
 
+##### .arrayLike(value)
+
+A `value` is array-like if it is not a function and has a `value.length` that is a safe integer greater than or equal to 0.
+
+```js
+is.arrayLike(document.forms);
+//=> true
+
+function () {
+    is.arrayLike(arguments);
+    //=> true
+}
+```
+
 ##### .inRange(value, range)
 
 Check if `value` (number) is in the given `range`. The range is an array of two values, lower bound and upper bound, in no specific order.
@@ -261,6 +275,7 @@ The most common mistakes I noticed in these modules was using `instanceof` for t
 
 - [Sindre Sorhus](https://github.com/sindresorhus)
 - [Giora Guttsait](https://github.com/gioragutt)
+- [Brandon Smith](https://github.com/brandon93s)
 
 
 ## License


Test patch:
diff --git a/test.js b/test.js
index f35eb08..8b7967c 100644
--- a/test.js
+++ b/test.js
@@ -392,6 +392,18 @@ test('is.typedArray', t => {
 	t.false(m.typedArray({}));
 });
 
+test('is.arrayLike', t => {
+	(() => {
+		t.true(m.arrayLike(arguments));
+	})();
+	t.true(m.arrayLike([]));
+	t.true(m.arrayLike('unicorn'));
+
+	t.false(m.arrayLike({}));
+	t.false(m.arrayLike(() => {}));
+	t.false(m.arrayLike(new Map()));
+});
+
 test('is.inRange', t => {
 	const x = 3;
Repository: sindresorhus/mem
Pull request #44 (2019-07-27 12:20:51)

Throw when `.clear()` is called with a non-memoized function
This aligns the behavior with `p-memoize`, if it's desirable.

Breaking change


Patch:
diff --git a/index.js b/index.js
index 34de26c..73b1b25 100644
--- a/index.js
+++ b/index.js
@@ -67,9 +67,12 @@ const mem = (fn, {
 module.exports = mem;
 
 module.exports.clear = fn => {
-	const cache = cacheStore.get(fn);
+	if (!cacheStore.has(fn)) {
+		throw new Error('Can\'t clear a function that was not memoized!');
+	}
 
-	if (cache && typeof cache.clear === 'function') {
+	const cache = cacheStore.get(fn);
+	if (typeof cache.clear === 'function') {
 		cache.clear();
 	}
 };


Test patch:
diff --git a/test.js b/test.js
index a85db05..aa18a59 100644
--- a/test.js
+++ b/test.js
@@ -238,3 +238,9 @@ test('prototype support', t => {
 	t.is(unicorn.foo(), 0);
 	t.is(unicorn.foo(), 0);
 });
+
+test('mem.clear() throws when called with a plain function', t => {
+	t.throws(() => {
+		mem.clear(() => {});
+	}, 'Can\'t clear a function that was not memoized!');
+});