Skip to content

Commit

Permalink
issue-#57 - Updated some '_platform' module docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
elycruz committed Feb 25, 2024
1 parent 9fe7123 commit f077329
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
5 changes: 2 additions & 3 deletions packages/fjl/src/_platform/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
## platform/
## _platform/

Platform specific, "functional version" methods.

*Note:* This directory doesn't get exported in the project, directly, however modules from this directory get exported via other exports (in '../function', '../object' modules, etc., for example), usually under aliases, or are just used in those (other) modules, etc..

*Note:* This directory doesn't get exported "directly" in the project, instead it is exported as the `platform` module. Additionally, some of its members get individually exported by other modules (for instance `instanceOf` gets exported by '../object' module as well).
2 changes: 1 addition & 1 deletion packages/fjl/src/_platform/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @module platform
* @module _platform
*/
export * from './object';
export * from './slice';
Expand Down
15 changes: 13 additions & 2 deletions packages/fjl/src/_platform/object/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* Defines (object) platform functional method counter-parts used in the library.
* Defines `Object` platform functional method counter-parts used in the library.
*/

import {flip, flip3, flip4, flip5} from "../../function/flip";
import {Constructable, ObjectStatics} from "../../types";

Expand Down Expand Up @@ -67,17 +66,29 @@ export const
return agg;
}, {}) as ObjectStatics,

/**
* Functional version of `instanceof` operator.
*/
instanceOf = (x: any, X: Constructable): boolean =>
x.constructor === X || x instanceof X,

/**
* Curried version of `instanceOf`.
*/
$instanceOf = (x: any) => (X: Constructable): boolean => instanceOf(x, X),

/**
* Functional version of `Object.prototype.hasOwnProperty`.
*/
hasOwnProperty = Object.hasOwn ?? (<T extends object>(x: T, key: string | PropertyKey): boolean =>
// @note `Object.hasOwn` cannot be used here until it is more broadly
// adopted (until node v24+ release etc.).
Object.prototype.hasOwnProperty.call(x, key))
,

/**
* Curried version of `hasOwnProperty`.
*/
$hasOwnProperty = <T extends object>(x: T) =>
(key: string | PropertyKey): boolean => hasOwnProperty(x, key)

Expand Down
3 changes: 3 additions & 0 deletions packages/fjl/src/_platform/slice/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Methods that apply to the `Slice` Sum Type (e.g., intersection of `Array` and `String` types).
*/
export const

/**
Expand Down
3 changes: 3 additions & 0 deletions packages/fjl/src/_platform/string/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Platform (string) specific combinators.
*/
export const split = (pattern: string | RegExp, xs: string, limit?: number): string[] => xs?.split(pattern, limit),

$split = (p: string) => (xs: string): string[] => split(p, xs);

0 comments on commit f077329

Please sign in to comment.