Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoSign in
Socket

quansync

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quansync - npm Package Compare versions

Comparing version
0.2.7
to
0.2.8
+11
-8
dist/index.cjs
'use strict';
const GET_IS_ASYNC = Symbol.for("quansync.getIsAsync");
const ERROR_PROMISE_IN_SYNC = "[Quansync] Yielded an unexpected promise in sync context";
class QuansyncError extends Error {
constructor(message = "Unexpected promise in sync context") {
super(message);
this.name = "QuansyncError";
}
}
function isThenable(value) {
return value && typeof value === "object" && typeof value.then === "function";
}
function isGenerator(value) {
return value && typeof value === "object" && typeof value[Symbol.iterator] === "function";
}
function isQuansyncGenerator(value) {
return isGenerator(value) && "__quansync" in value;
return value && typeof value === "object" && typeof value[Symbol.iterator] === "function" && "__quansync" in value;
}

@@ -36,3 +38,3 @@ function fromObject(options) {

if (isThenable(promise))
throw new Error(ERROR_PROMISE_IN_SYNC);
throw new QuansyncError();
return promise;

@@ -48,3 +50,3 @@ }

if (!isAsync && isThenable(value))
throw new Error(ERROR_PROMISE_IN_SYNC);
throw new QuansyncError();
return value;

@@ -94,3 +96,3 @@ }

function toGenerator(promise) {
if (isGenerator(promise))
if (isQuansyncGenerator(promise))
return promise;

@@ -101,3 +103,4 @@ return fromPromise(promise)();

exports.GET_IS_ASYNC = GET_IS_ASYNC;
exports.QuansyncError = QuansyncError;
exports.quansync = quansync;
exports.toGenerator = toGenerator;

@@ -5,2 +5,5 @@ import { QuansyncInput, QuansyncFn, QuansyncGenerator } from './types.cjs';

declare const GET_IS_ASYNC: unique symbol;
declare class QuansyncError extends Error {
constructor(message?: string);
}
/**

@@ -15,2 +18,2 @@ * Creates a new Quansync function, a "superposition" between async and sync.

export { GET_IS_ASYNC, QuansyncFn, QuansyncGenerator, QuansyncInput, quansync, toGenerator };
export { GET_IS_ASYNC, QuansyncError, QuansyncFn, QuansyncGenerator, QuansyncInput, quansync, toGenerator };

@@ -5,2 +5,5 @@ import { QuansyncInput, QuansyncFn, QuansyncGenerator } from './types.mjs';

declare const GET_IS_ASYNC: unique symbol;
declare class QuansyncError extends Error {
constructor(message?: string);
}
/**

@@ -15,2 +18,2 @@ * Creates a new Quansync function, a "superposition" between async and sync.

export { GET_IS_ASYNC, QuansyncFn, QuansyncGenerator, QuansyncInput, quansync, toGenerator };
export { GET_IS_ASYNC, QuansyncError, QuansyncFn, QuansyncGenerator, QuansyncInput, quansync, toGenerator };

@@ -5,2 +5,5 @@ import { QuansyncInput, QuansyncFn, QuansyncGenerator } from './types.js';

declare const GET_IS_ASYNC: unique symbol;
declare class QuansyncError extends Error {
constructor(message?: string);
}
/**

@@ -15,2 +18,2 @@ * Creates a new Quansync function, a "superposition" between async and sync.

export { GET_IS_ASYNC, QuansyncFn, QuansyncGenerator, QuansyncInput, quansync, toGenerator };
export { GET_IS_ASYNC, QuansyncError, QuansyncFn, QuansyncGenerator, QuansyncInput, quansync, toGenerator };
const GET_IS_ASYNC = Symbol.for("quansync.getIsAsync");
const ERROR_PROMISE_IN_SYNC = "[Quansync] Yielded an unexpected promise in sync context";
class QuansyncError extends Error {
constructor(message = "Unexpected promise in sync context") {
super(message);
this.name = "QuansyncError";
}
}
function isThenable(value) {
return value && typeof value === "object" && typeof value.then === "function";
}
function isGenerator(value) {
return value && typeof value === "object" && typeof value[Symbol.iterator] === "function";
}
function isQuansyncGenerator(value) {
return isGenerator(value) && "__quansync" in value;
return value && typeof value === "object" && typeof value[Symbol.iterator] === "function" && "__quansync" in value;
}

@@ -34,3 +36,3 @@ function fromObject(options) {

if (isThenable(promise))
throw new Error(ERROR_PROMISE_IN_SYNC);
throw new QuansyncError();
return promise;

@@ -46,3 +48,3 @@ }

if (!isAsync && isThenable(value))
throw new Error(ERROR_PROMISE_IN_SYNC);
throw new QuansyncError();
return value;

@@ -92,3 +94,3 @@ }

function toGenerator(promise) {
if (isGenerator(promise))
if (isQuansyncGenerator(promise))
return promise;

@@ -98,2 +100,2 @@ return fromPromise(promise)();

export { GET_IS_ASYNC, quansync, toGenerator };
export { GET_IS_ASYNC, QuansyncError, quansync, toGenerator };
{
"name": "quansync",
"type": "module",
"version": "0.2.7",
"version": "0.2.8",
"description": "Create sync/async APIs with usable logic",

@@ -65,4 +65,4 @@ "author": "Anthony Fu <anthonyfu117@hotmail.com>",

"devDependencies": {
"@antfu/eslint-config": "^4.3.0",
"@types/node": "^22.13.5",
"@antfu/eslint-config": "^4.4.0",
"@types/node": "^22.13.8",
"bumpp": "^10.0.3",

@@ -75,3 +75,3 @@ "eslint": "^9.21.0",

"tsx": "^4.19.3",
"typescript": "^5.7.3",
"typescript": "^5.8.2",
"unbuild": "^3.5.0",

@@ -78,0 +78,0 @@ "vite": "^6.2.0",

@@ -38,3 +38,3 @@ # quansync

// Use `yield*` to call another quansync function
const code = yield * readFile(filename, 'utf8')
const code = yield* readFile(filename, 'utf8')

@@ -41,0 +41,0 @@ return `// some custom prefix\n${code}`