Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@thi.ng/wasm-api

Package Overview
Dependencies
Maintainers
1
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/wasm-api - npm Package Compare versions

Comparing version 0.16.0 to 0.17.0

14

api.d.ts

@@ -1,2 +0,2 @@

import type { BigType, FloatType, Fn, Fn2, IDeref, ILength, IObjectOf } from "@thi.ng/api";
import type { BigType, FloatType, Fn, Fn2, IDeref, ILength, IObjectOf, NumOrString } from "@thi.ng/api";
import type { Pow2 } from "@thi.ng/binary";

@@ -227,3 +227,3 @@ import type { WasmBridge } from "./bridge.js";

};
export declare type TypeColl = Record<string, TopLevelType>;
export declare type TypeColl = IObjectOf<TopLevelType>;
export interface TypeInfo {

@@ -374,6 +374,10 @@ /**

/**
* Currently only supported for {@link ZIG} scalar & string values,
* otherwise ignored!
* Currently only supported for {@link ZIG}, otherwise ignored!
*
* @remarks
* The object form allows for different default values per language (in
* theory). So if given as object, the keys refer to the lang ID and the
* values as the defaults for those languages.
*/
default?: number;
default?: NumOrString | IObjectOf<NumOrString>;
/**

@@ -380,0 +384,0 @@ * If defined and > 0, the field will be considered for padding purposes

# Change Log
- **Last updated**: 2022-10-28T19:08:39Z
- **Last updated**: 2022-10-29T20:34:04Z
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)

@@ -12,2 +12,16 @@

## [0.17.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/wasm-api@0.17.0) (2022-10-29)
#### 🚀 Features
- update default value format & handling ([c7752fb](https://github.com/thi-ng/umbrella/commit/c7752fb))
- update Field.default to support lang-specific alts
- add defaultValue() helper
- update zig codegen
#### 🩹 Bug fixes
- fix idempotence checks for self-referential types ([2c3f670](https://github.com/thi-ng/umbrella/commit/2c3f670))
- update prepareType()
## [0.16.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/wasm-api@0.16.0) (2022-10-28)

@@ -14,0 +28,0 @@

@@ -116,3 +116,3 @@ import { SIZEOF } from "@thi.ng/api/typedarray";

[DEFAULT]: (x, types, alignImpl, opts) => {
if (x.__align && x.__size)
if (x.__align)
return;

@@ -123,3 +123,3 @@ alignOf(x, types, alignImpl, opts);

struct: (x, types, align, opts) => {
if (x.__align && x.__size)
if (x.__align)
return;

@@ -126,0 +126,0 @@ const struct = x;

@@ -63,2 +63,10 @@ import type { BigType } from "@thi.ng/api";

/**
* Returns given field's default value (or undefined). The `lang` ID is required
* to obtain the language specific value if the default is given as object.
*
* @param f
* @param lang
*/
export declare const defaultValue: (f: Field, lang: string) => import("@thi.ng/api").NumOrString | undefined;
/**
* Takes an array of strings or splits given string into lines, word wraps and

@@ -65,0 +73,0 @@ * then prefixes each line with given `width` and `prefix`. Returns array of new

import { isArray } from "@thi.ng/checks/is-array";
import { isPlainObject } from "@thi.ng/checks/is-plain-object";
import { isString } from "@thi.ng/checks/is-string";

@@ -65,2 +66,14 @@ import { split } from "@thi.ng/strings/split";

/**
* Returns given field's default value (or undefined). The `lang` ID is required
* to obtain the language specific value if the default is given as object.
*
* @param f
* @param lang
*/
export const defaultValue = (f, lang) => f.default !== undefined
? isPlainObject(f.default)
? f.default[lang]
: f.default
: undefined;
/**
* Takes an array of strings or splits given string into lines, word wraps and

@@ -67,0 +80,0 @@ * then prefixes each line with given `width` and `prefix`. Returns array of new

@@ -1,5 +0,5 @@

import { isNumber } from "@thi.ng/checks/is-number";
import { isNumber } from "@thi.ng/checks";
import { isString } from "@thi.ng/checks/is-string";
import { unsupported } from "@thi.ng/errors/unsupported";
import { ensureLines, enumName, isPadding, isStringSlice, isWasmString, prefixLines, withIndentation, } from "./utils.js";
import { defaultValue, ensureLines, enumName, isPadding, isStringSlice, isWasmString, prefixLines, withIndentation, } from "./utils.js";
/**

@@ -112,3 +112,3 @@ * Zig code generator. Call with options and then pass to {@link generateTypes}

: f.type;
let defaultVal = "";
let defaultVal = defaultValue(f, "zig");
switch (f.tag) {

@@ -132,10 +132,12 @@ case "array":

default:
if (f.default != undefined) {
if (!(isString(f.default) || isNumber(f.default))) {
unsupported(`wrong default value for ${parent.name}.${f.name} (${f.default})`);
if (defaultVal != undefined) {
if (!(isString(defaultVal) || isNumber(defaultVal))) {
unsupported(`wrong default value for ${parent.name}.${f.name} (${defaultVal})`);
}
defaultVal = ` = ${JSON.stringify(f.default)}`;
}
}
return { type, defaultVal };
return {
type,
defaultVal: defaultVal != undefined ? ` = ${defaultVal}` : "",
};
};

@@ -142,0 +144,0 @@ const __packedPadding = (id, n, res) => {

{
"name": "@thi.ng/wasm-api",
"version": "0.16.0",
"version": "0.17.0",
"description": "Generic, modular, extensible API bridge, polyglot glue code and bindings code generators for hybrid JS & WebAssembly projects",

@@ -144,3 +144,3 @@ "type": "module",

},
"gitHead": "41e59c7ad9bf24bb0230a5f60d05715e0fc1c1e6\n"
"gitHead": "0402675247b1c312e4dd3d9bc6c01af5cc837c5d\n"
}
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