-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
66 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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 isObject from 'lodash-es/isObject'; | ||
|
||
console.log(isObject(1), isObject({})); |
3 changes: 3 additions & 0 deletions
3
projects/micro-dash-sizes/src/app/lang/is-object.microdash.ts
This file contains 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 { isObject } from '@s-libs/micro-dash'; | ||
|
||
console.log(isObject(1), isObject({})); |
This file contains 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
This file contains 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
This file contains 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,39 @@ | ||
import { isObject } from './is-object'; | ||
|
||
describe('isObject()', () => { | ||
function getArguments(): IArguments { | ||
return arguments; | ||
} | ||
|
||
// | ||
// stolen from https://github.com/lodash/lodash | ||
// | ||
|
||
it('should return `true` for objects', () => { | ||
expect(isObject(getArguments())).toBe(true); | ||
expect(isObject([1, 2, 3])).toBe(true); | ||
expect(isObject(Object(false))).toBe(true); | ||
expect(isObject(new Date())).toBe(true); | ||
expect(isObject(new Error())).toBe(true); | ||
expect(isObject(Array.prototype.slice)).toBe(true); | ||
expect(isObject({ a: 1 })).toBe(true); | ||
expect(isObject(Object(0))).toBe(true); | ||
expect(isObject(/x/)).toBe(true); | ||
expect(isObject(Object('a'))).toBe(true); | ||
expect(isObject(document.body)).toBe(true); | ||
expect(isObject(Object(Symbol('a')))).toBe(true); | ||
}); | ||
|
||
it('should return `false` for non-objects', () => { | ||
expect(isObject(null)).toBe(false); | ||
expect(isObject(undefined)).toBe(false); | ||
expect(isObject(false)).toBe(false); | ||
expect(isObject(0)).toBe(false); | ||
expect(isObject(NaN)).toBe(false); | ||
expect(isObject('')).toBe(false); | ||
expect(isObject(true)).toBe(false); | ||
expect(isObject(1)).toBe(false); | ||
expect(isObject('a')).toBe(false); | ||
expect(isObject(Symbol('a'))).toBe(false); | ||
}); | ||
}); |
This file contains 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 @@ | ||
/** | ||
* Checks if `value` is the [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) of `Object`. _(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)_ | ||
* | ||
* Contribution to minified bundle size, when it is the only function imported: | ||
* - Lodash: 105 bytes | ||
* - Micro-dash: 41 bytes | ||
*/ | ||
export function isObject(value: any): value is object { | ||
return value instanceof Object; | ||
} |