@dogsbay/literal 0.2.0-beta.138 → 0.2.0-beta.140

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -61,6 +61,11 @@ export interface EvaluateOptions {
61
61
  * `const config = { … }; export { config }`.
62
62
  */
63
63
  export declare function evaluateModule(source: string, fallbackExport?: string, opts?: EvaluateOptions): EvalResult;
64
+ /**
65
+ * Evaluate ONE named top-level binding (`const products = […]`), exported or not, and nothing
66
+ * else: what the default export does (a component rendering JSX) cannot make the read fail.
67
+ */
68
+ export declare function evaluateBinding(source: string, name: string, opts?: EvaluateOptions): EvalResult;
64
69
  /** Narrowing helper: a plain object with no UNRESOLVED identity. */
65
70
  export declare function asObject(v: LiteralValue): Record<string, LiteralValue> | undefined;
66
71
  export declare function asArray(v: LiteralValue): LiteralValue[] | undefined;
package/dist/index.js CHANGED
@@ -1158,6 +1158,15 @@ export function evaluateModule(source, fallbackExport = "config", opts = {}) {
1158
1158
  }
1159
1159
  return { value, unresolved: ev.unresolved };
1160
1160
  }
1161
+ /**
1162
+ * Evaluate ONE named top-level binding (`const products = […]`), exported or not, and nothing
1163
+ * else: what the default export does (a component rendering JSX) cannot make the read fail.
1164
+ */
1165
+ export function evaluateBinding(source, name, opts = {}) {
1166
+ const ev = new Evaluator(source, opts);
1167
+ const value = ev.hasBinding(name) ? ev.resolveBinding(name) : UNRESOLVED;
1168
+ return { value, unresolved: ev.unresolved };
1169
+ }
1161
1170
  /** Narrowing helper: a plain object with no UNRESOLVED identity. */
1162
1171
  export function asObject(v) {
1163
1172
  if (v && typeof v === "object" && !Array.isArray(v)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dogsbay/literal",
3
- "version": "0.2.0-beta.138",
3
+ "version": "0.2.0-beta.140",
4
4
  "description": "Read a JavaScript/TypeScript config module as data without running it: object and array literals, spreads, module-level constants, zero-argument helpers and wrapper calls; anything else is reported, never guessed. No Node, no dependencies",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",