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

@hypermode/functions-as

Package Overview
Dependencies
Maintainers
0
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hypermode/functions-as - npm Package Compare versions

Comparing version

to
0.12.0-alpha1

2

package.json
{
"name": "@hypermode/functions-as",
"version": "0.11.3-alpha1",
"version": "0.12.0-alpha1",
"description": "Hypermode library for AssemblyScript functions",

@@ -5,0 +5,0 @@ "author": "Hypermode, Inc.",

@@ -29,3 +29,3 @@ import binaryen from "assemblyscript/lib/binaryen.js";

.flatMap((f) => f.parameters.map((p) => p.type).concat(f.results[0]?.type))
.map((p) => p?.replace(/\|null$/, "")));
.map((p) => makeNonNullable(p)));
const typesUsed = new Map();

@@ -51,6 +51,3 @@ allTypes.forEach((t) => {

type.fields.forEach((f) => {
let path = f.type;
if (path.endsWith("|null")) {
path = path.slice(0, -5);
}
const path = makeNonNullable(f.type);
const typeDef = allTypes.get(path);

@@ -148,11 +145,12 @@ if (typeDef) {

export function getTypeName(path) {
const isNullable = path.endsWith("|null");
if (path.startsWith("~lib/array/Array")) {
const type = getTypeName(path.slice(path.indexOf("<") + 1, path.lastIndexOf(">")));
if (isNullable)
if (isNullable(type)) {
return "(" + type + ")[]";
}
return type + "[]";
}
if (isNullable)
return getTypeName(path.slice(0, path.length - 5)) + " | null";
if (isNullable(path)) {
return makeNullable(getTypeName(makeNonNullable(path)));
}
const name = typeMap.get(path);

@@ -162,5 +160,4 @@ if (name)

if (path.startsWith("~lib/map/Map")) {
const firstType = getTypeName(path.slice(path.indexOf("<") + 1, path.indexOf(",")));
const secondType = getTypeName(path.slice(path.indexOf(",") + 1, path.lastIndexOf(">")));
return "Map<" + firstType + ", " + secondType + ">";
const [keyType, valueType] = getMapSubtypes(path);
return "Map<" + getTypeName(keyType) + ", " + getTypeName(valueType) + ">";
}

@@ -214,2 +211,43 @@ if (path.startsWith("~lib/@hypermode")) {

}
const nullableTypeRegex = /\s?\|\s?null$/;
function isNullable(type) {
return nullableTypeRegex.test(type);
}
function makeNonNullable(type) {
return type?.replace(nullableTypeRegex, "");
}
function makeNullable(type) {
if (isNullable(type)) {
return type;
}
else {
return type + " | null";
}
}
function getMapSubtypes(type) {
const prefix = "~lib/map/Map<";
if (!type.startsWith(prefix)) {
return ["", ""];
}
let n = 1;
let c = 0;
for (let i = prefix.length; i < type.length; i++) {
switch (type.charAt(i)) {
case "<":
n++;
break;
case ",":
if (n == 1) {
c = i;
}
break;
case ">":
n--;
if (n == 0) {
return [type.slice(prefix.length, c), type.slice(c + 1, i)];
}
}
}
return ["", ""];
}
//# sourceMappingURL=extractor.js.map