@helios-lang/type-utils
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -14,3 +14,3 @@ { | ||
"exclude": ["node_modules"], | ||
"include": ["src/global.d.ts", "src/**/*.js"] | ||
"include": ["src/index.d.ts", "src/**/*.js"] | ||
} |
{ | ||
"name": "@helios-lang/type-utils", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Global utility types", | ||
"main": "src/index.js", | ||
"types": "src/global.d.ts", | ||
"types": "src/index.d.ts", | ||
"type": "module", | ||
"scripts": { | ||
"build": "npm test", | ||
"clean": "find src/ -name *[!global].d.ts* | xargs rm -f", | ||
"postpublish": "npm run clean", | ||
"prebuild": "npm run clean && npx tsc -p jsconfig.json --noEmit false --emitDeclarationOnly", | ||
"prepare": "npm run build", | ||
@@ -14,0 +11,0 @@ "prettify": "npx prettier . --write", |
@@ -1,2 +0,10 @@ | ||
export { isNone, isSome, None } from "./option.js"; | ||
//# sourceMappingURL=index.d.ts.map | ||
export {} | ||
declare global { | ||
type Option<T> = null | undefined | T | ||
const None: null | ||
function isNone<T>(option: Option<T>): option is (null | undefined) | ||
function isSome<T>(option: Option<T>): option is T | ||
} |
@@ -1,1 +0,22 @@ | ||
export { isNone, isSome, None } from "./option.js" | ||
/** | ||
* @type {null} | ||
*/ | ||
export const None = null | ||
/** | ||
* @template T | ||
* @param {Option<T>} opt | ||
* @returns {opt is T} | ||
*/ | ||
export function isSome(opt) { | ||
return opt !== null && opt !== undefined | ||
} | ||
/** | ||
* @template T | ||
* @param {Option<T>} opt | ||
* @returns {opt is (null | undefined)} | ||
*/ | ||
export function isNone(opt) { | ||
return opt === null || opt === undefined | ||
} |
3326
6
42