mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-24 05:34:47 +08:00
(feature) Add _.isArrayLike and _.isArrayLikeObject
This commit is contained in:
@@ -5738,6 +5738,78 @@ module TestIsArray {
|
||||
}
|
||||
}
|
||||
|
||||
// _.isArrayLike
|
||||
module TestIsArrayLike {
|
||||
{
|
||||
let value: number|string[]|boolean[];
|
||||
|
||||
if (_.isArrayLike<string>(value)) {
|
||||
let result: string[] = value;
|
||||
}
|
||||
else {
|
||||
if (_.isArrayLike<boolean>(value)) {
|
||||
let result: boolean[] = value;
|
||||
}
|
||||
else {
|
||||
let result: number = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
let result: boolean;
|
||||
|
||||
result = _.isArrayLike(any);
|
||||
result = _(1).isArrayLike();
|
||||
result = _<any>([]).isArrayLike();
|
||||
result = _({}).isArrayLike();
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitWrapper<boolean>;
|
||||
|
||||
result = _(1).chain().isArrayLike();
|
||||
result = _<any>([]).chain().isArrayLike();
|
||||
result = _({}).chain().isArrayLike();
|
||||
}
|
||||
}
|
||||
|
||||
// _.isArrayLikeObject
|
||||
module TestIsArrayLikeObject {
|
||||
{
|
||||
let value: number|string[]|boolean[];
|
||||
|
||||
if (_.isArrayLikeObject<string>(value)) {
|
||||
let result: string[] = value;
|
||||
}
|
||||
else {
|
||||
if (_.isArrayLikeObject<boolean>(value)) {
|
||||
let result: boolean[] = value;
|
||||
}
|
||||
else {
|
||||
let result: number = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
let result: boolean;
|
||||
|
||||
result = _.isArrayLikeObject(any);
|
||||
result = _(1).isArrayLikeObject();
|
||||
result = _<any>([]).isArrayLikeObject();
|
||||
result = _({}).isArrayLikeObject();
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitWrapper<boolean>;
|
||||
|
||||
result = _(1).chain().isArrayLikeObject();
|
||||
result = _<any>([]).chain().isArrayLikeObject();
|
||||
result = _({}).chain().isArrayLikeObject();
|
||||
}
|
||||
}
|
||||
|
||||
// _.isBoolean
|
||||
module TestIsBoolean {
|
||||
{
|
||||
|
||||
Vendored
+89
-2
@@ -120,8 +120,8 @@ added 8 string methods:
|
||||
- [ ] _.split
|
||||
- [x] _.upperCase
|
||||
- [x] _.upperFirst
|
||||
- [ ] _.toLower
|
||||
- [ ] _.toUpper
|
||||
- [x] _.toLower
|
||||
- [x] _.toUpper
|
||||
|
||||
added 8 utility methods:
|
||||
- [ ] _.cond
|
||||
@@ -9373,6 +9373,93 @@ declare module _ {
|
||||
isArray(): LoDashExplicitWrapper<boolean>;
|
||||
}
|
||||
|
||||
//_.isArrayLike
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Checks if `value` is array-like. A value is considered array-like if it's
|
||||
* not a function and has a `value.length` that's an integer greater than or
|
||||
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @type Function
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isArrayLike([1, 2, 3]);
|
||||
* // => true
|
||||
*
|
||||
* _.isArrayLike(document.body.children);
|
||||
* // => true
|
||||
*
|
||||
* _.isArrayLike('abc');
|
||||
* // => true
|
||||
*
|
||||
* _.isArrayLike(_.noop);
|
||||
* // => false
|
||||
*/
|
||||
isArrayLike<T>(value?: any): value is T[];
|
||||
}
|
||||
|
||||
interface LoDashImplicitWrapperBase<T,TWrapper> {
|
||||
/**
|
||||
* @see _.isArrayLike
|
||||
*/
|
||||
isArrayLike(): boolean;
|
||||
}
|
||||
|
||||
interface LoDashExplicitWrapperBase<T,TWrapper> {
|
||||
/**
|
||||
* @see _.isArrayLike
|
||||
*/
|
||||
isArrayLike(): LoDashExplicitWrapper<boolean>;
|
||||
}
|
||||
|
||||
//_.isArrayLikeObject
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* This method is like `_.isArrayLike` except that it also checks if `value`
|
||||
* is an object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @type Function
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is an array-like object, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isArrayLikeObject([1, 2, 3]);
|
||||
* // => true
|
||||
*
|
||||
* _.isArrayLikeObject(document.body.children);
|
||||
* // => true
|
||||
*
|
||||
* _.isArrayLikeObject('abc');
|
||||
* // => false
|
||||
*
|
||||
* _.isArrayLikeObject(_.noop);
|
||||
* // => false
|
||||
*/
|
||||
isArrayLikeObject<T>(value?: any): value is T[];
|
||||
}
|
||||
|
||||
interface LoDashImplicitWrapperBase<T,TWrapper> {
|
||||
/**
|
||||
* @see _.isArrayLikeObject
|
||||
*/
|
||||
isArrayLikeObject(): boolean;
|
||||
}
|
||||
|
||||
interface LoDashExplicitWrapperBase<T,TWrapper> {
|
||||
/**
|
||||
* @see _.isArrayLikeObject
|
||||
*/
|
||||
isArrayLikeObject(): LoDashExplicitWrapper<boolean>;
|
||||
}
|
||||
|
||||
//_.isBoolean
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user