New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@helios-lang/type-utils

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@helios-lang/type-utils - npm Package Compare versions

Comparing version 0.1.14 to 0.1.15

2

package.json
{
"name": "@helios-lang/type-utils",
"version": "0.1.14",
"version": "0.1.15",
"description": "Global utility types",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -48,1 +48,7 @@ declare global {

}
export function isJsonSafe(input: unknown): input is JsonSafe
export function expectJsonSafe(
input: unknown,
msg?: string | undefined
): asserts input is JsonSafe

@@ -1,4 +0,4 @@

export { JSONSafe as JSON } from "./json.js"
export { JSONSafe as JSON, isJsonSafe, expectJsonSafe } from "./json.js"
export * from "./either.js"
export { expectEnum } from "./enum.js"
export * from "./option.js"

@@ -5,1 +5,36 @@ export const JSONSafe = {

}
/**
* @param {unknown} input
* @returns {input is JsonSafe}
*/
export function isJsonSafe(input) {
if (typeof input == "number") {
return true
} else if (typeof input == "string") {
return true
} else if (typeof input == "boolean") {
return true
} else if (input === null) {
return true
} else if (Array.isArray(input)) {
return input.every(isJsonSafe)
} else if (typeof input == "object") {
return Object.keys(input).every((key) => isJsonSafe(input[key]))
} else {
return false
}
}
/**
* @param {unknown} input
* @param {string | undefined} msg
* @returns {asserts input is JsonSafe}
*/
export function expectJsonSafe(input, msg = undefined) {
if (isJsonSafe(input)) {
return
} else {
throw new TypeError(msg ?? "invalid JsonSafe value")
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc