-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add predicate functions of basic types like Promise
, Date
, Iterable
, etc.
#118
Comments
Are they added under import { isPromise } from "@core/unknownutil/is/promise";
import { is } from "@core/unknownutil/is";
const x: unknown = 0;
isPromise(x);
is.Promise(x); |
type Jsonable = {
/**
* Returns a JSON value that can be specified to {@linkcode JSON.stringify}.
*
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#tojson_behavior|toJSON() behavior}
*/
toJSON(key: string | number): unknown;
};
function isJsonable(x: unknown): x is Jsonable {
return x != null && isFunction((x as Jsonable).toJSON);
} 💭 I wonder if we define this in unknownutil. Originally posted by @lambdalisue in vim-denops/deno-denops-std#260 (comment) |
const isInstanceOfBoolean = isInstanceOf(Boolean);
const isInstanceOfNumber = isInstanceOf(Number);
const isInstanceOfString = isInstanceOf(String); 💭 I wonder if we define these in unknownutil like Originally posted by @lambdalisue in vim-denops/deno-denops-std#260 (comment) |
I think null is jsonable |
Discussion and implementation of |
I changed my mind. It's impossible to define "what is the bacis types". |
We can use
isInstanceOf
orisObjectOf
now but for convinience.Promise
Date
Temporal
Worker
Iterable
AsyncIterable
Disposable
AsyncDisposable
The text was updated successfully, but these errors were encountered: