Skip to content

Commit

Permalink
issue-#57, #96 - Replaced uses of 'isset' in fjl package..
Browse files Browse the repository at this point in the history
  • Loading branch information
elycruz committed Feb 27, 2024
1 parent 6b0eea2 commit dff7723
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/fjl/src/object/is.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export const
* isType(Number, NaN) === false
* isType(Number, 99) === true
* isType('Null', 99) === false // though, for `null` and `undefined` checks
* // @see `isset`, in this module, instead
* // @see `isNullish`/`notNullish`, in this module, instead
* isType('Undefined', undefined) === true // true
*
* @note Useful where absolute types, or some semblance thereof, are required.
Expand All @@ -271,7 +271,7 @@ export const
* on value with constructor.
* @note Use care when checking for `Array` since it is an `instanceof` Object.
* @note For `null` and `undefined` their class cased names can be used for type checks
* `isOfType('Null', null) === true (passes strict type check)` (or better yet @link `module:object.isset` can be used).
* `isOfType('Null', null) === true (passes strict type check)` (or better yet @link `module:object.notNullish` can be used).
* @throwsafe - Doesn't throw on `null` or `undefined` `obj` values.
* @example
* isOfType(Number, 99) === true // true (passes strict type check (numbers are not instances of `Number`
Expand Down
8 changes: 4 additions & 4 deletions packages/fjl/src/object/of.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {isConstructablePrimitive} from './is';
import {isset} from './isset';
import {isConstructablePrimitive, isNullish} from './is';
import {Constructable} from "../types";

/**
Expand All @@ -13,10 +12,11 @@ import {Constructable} from "../types";
* - Else if constructor is an instance of `Function`,
* calls constructor, using the `new` keyword (with any
* passed in args).
* - Else returns nothing.
* - Else returns void.
*/
export const of = <T>(x: T, ...args: any[]): T => {
if (!isset(x)) return undefined;
if (isNullish(x))
return undefined;

const constructor = x.constructor as Constructable;

Expand Down
4 changes: 2 additions & 2 deletions packages/fjl/src/object/searchObj.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {isset} from './is';
import {notNullish} from './is';

export const

Expand Down Expand Up @@ -39,7 +39,7 @@ export const
parent = obj;
for (; ind < limit; ind += 1) {
const node = parent[parts[ind]];
if (!isset(node)) {
if (notNullish(node)) {
return node;
}
parent = node;
Expand Down
2 changes: 1 addition & 1 deletion packages/fjl/tests/object/index_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ describe('#object', function () {
[1, false],
])
.forEach(([arg, expected]) => {
it(`isEmpty(${(isset(arg) && arg instanceof Function) || arg === null ? arg + '' : stringify(arg)}) === ${expected}`, function () {
it(`isEmpty(${((arg === null || arg === undefined) && arg instanceof Function) || arg === null ? arg + '' : stringify(arg)}) === ${expected}`, function () {
expect(isEmpty(arg)).toEqual(expected);
});
});
Expand Down

0 comments on commit dff7723

Please sign in to comment.