CodeSampleX

示例

@vue/shared 3.5.41: looseEqual, normalizeClass, normalizeStyle

已验证示例 — npm @vue/shared 3.5.41: looseEqual, normalizeClass, normalizeStyle. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过.

sha256:aee49d988b961d9053602ebcc4afa031326c67f0c3c67162bc02147d0556dcf8

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。 MIT-0

执行证据

声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。

证据依据
签名契约通过
验证回执
1
构建过它的签名密钥
1
声明的环境 linux 24 · ubuntu · glibc 2.39 x64 npm

验证运行环境

环境 契约 阶段 运行日期
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-27

案例

HOW
目标
verify normalizeClass, normalizeStyle, and looseEqual in pkg:npm/%40vue/shared@3.5.41
包
符号
  • looseEqual
  • normalizeClass
  • normalizeStyle
创建时间
2026-08-27T15:50:43Z

契约

  1. normalizeClass flattens strings, string arrays, and object truthy boolean keys into space-separated class names
  2. normalizeClass recursively normalizes nested array and object structures and ignores falsy values
  3. parseStringStyle converts css text into key-value style map and stringifyStyle serializes style objects
  4. normalizeStyle preserves string styles, passes object styles, and merges array of styles
  5. looseEqual performs deep structural equality comparison across primitives, dates, regexes, arrays, and objects
  6. looseIndexOf finds element index in array using looseEqual semantics

文件

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

下载源代码构件 (tar.gz)

源代码

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify normalizeClass, normalizeStyle, and looseEqual in pkg:npm/%40vue/shared@3.5.41
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40vue/shared@3.5.41
Demonstrate these symbols/APIs:
  - looseEqual
  - normalizeClass
  - normalizeStyle

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:c65fe754abaab836da3f15d1687e27c4317b07c63d87987076a02866e7012979","contract":["normalizeClass flattens strings, string arrays, and object truthy boolean keys into space-separated class names","normalizeClass recursively normalizes nested array and object structures and ignores falsy values","parseStringStyle converts css text into key-value style map and stringifyStyle serializes style objects","normalizeStyle preserves string styles, passes object styles, and merges array of styles","looseEqual performs deep structural equality comparison across primitives, dates, regexes, arrays, and objects","looseIndexOf finds element index in array using looseEqual semantics"],"goal":"verify normalizeClass, normalizeStyle, and looseEqual in pkg:npm/%40vue/shared@3.5.41","kind":"HOW","packages":["pkg:npm/%40vue/shared@3.5.41"],"schemaVersion":1,"symbols":["looseEqual","normalizeClass","normalizeStyle"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40vue/shared@3.5.41"],"schemaVersion":1,"subject":"pkg:npm/%40vue/shared@3.5.41","symbols":["looseEqual","normalizeClass","normalizeStyle"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-vue-shared",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-vue-shared",
      "version": "1.0.0",
      "dependencies": {
        "@vue/shared": "3.5.41"
      }
    },
    "node_modules/@vue/shared": {
      "version": "3.5.41",
      "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.41.tgz",
      "integrity": "sha512-IOnwSCma8j+9xJT6b8H0dEYidC80NsYmNMlZxRsukYcSoGaDBohog5hDxzeUXdFeGWFA++vWvxqOmrr96VlqMA==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-vue-shared",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "@vue/shared": "3.5.41"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify normalizeClass, normalizeStyle, and looseEqual in pkg:npm/%40vue/shared@3.5.41",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40vue/shared@3.5.41"
  ],
  "symbols": [
    "looseEqual",
    "normalizeClass",
    "normalizeStyle"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import {
  normalizeClass,
  normalizeStyle,
  parseStringStyle,
  stringifyStyle,
  looseEqual,
  looseIndexOf
} from '@vue/shared';

// 1. normalizeClass flattens strings, string arrays, and object truthy boolean keys into space-separated class names
{
  assert.equal(normalizeClass('foo bar'), 'foo bar');
  assert.equal(normalizeClass(['foo', 'bar']), 'foo bar');
  assert.equal(normalizeClass({ foo: true, bar: false, baz: 1 }), 'foo baz');
}

// 2. normalizeClass recursively normalizes nested array and object structures and ignores falsy values
{
  assert.equal(
    normalizeClass(['foo', { bar: true, baz: false }, ['nested', { inner: true }], null, undefined, false]),
    'foo bar nested inner'
  );
  assert.equal(normalizeClass(null), '');
  assert.equal(normalizeClass(undefined), '');
  assert.equal(normalizeClass(false), '');
}

// 3. parseStringStyle converts css text into key-value style map and stringifyStyle serializes style objects
{
  assert.deepEqual(parseStringStyle('color: red; font-size: 14px;'), {
    color: 'red',
    'font-size': '14px'
  });
  assert.deepEqual(parseStringStyle('margin-top: 10px; opacity: 0.5;'), {
    'margin-top': '10px',
    opacity: '0.5'
  });
  assert.equal(stringifyStyle({ color: 'red', fontSize: '14px' }), 'color:red;font-size:14px;');
}

// 4. normalizeStyle preserves string styles, passes object styles, and merges array of styles
{
  assert.equal(normalizeStyle('color: red; font-size: 14px;'), 'color: red; font-size: 14px;');
  assert.deepEqual(normalizeStyle({ color: 'red', fontSize: '14px' }), {
    color: 'red',
    fontSize: '14px'
  });

  const merged = normalizeStyle([
    'color: red;',
    { fontSize: '12px' },
    { color: 'blue', fontWeight: 'bold' }
  ]);
  assert.deepEqual(merged, {
    color: 'blue',
    fontSize: '12px',
    fontWeight: 'bold'
  });
}

// 5. looseEqual performs deep structural equality comparison across primitives, dates, regexes, arrays, and objects
{
  assert.equal(looseEqual(1, 1), true);
  assert.equal(looseEqual('1', 1), true);
  assert.equal(looseEqual(new Date(1600000000000), new Date(1600000000000)), true);
  assert.equal(looseEqual(new Date(1600000000000), new Date(1700000000000)), false);
  assert.equal(looseEqual(/abc/g, /abc/g), true);
  assert.equal(looseEqual(/abc/g, /abc/i), false);
  assert.equal(looseEqual([1, 2, 3], [1, 2, 3]), true);
  assert.equal(looseEqual([1, 2], [1, 2, 3]), false);
  assert.equal(looseEqual({ a: 1, b: '2' }, { b: 2, a: 1 }), true);
}

// 6. looseIndexOf finds element index in array using looseEqual semantics
{
  const list = [1, { id: 1 }, { id: 2 }];
  assert.equal(looseIndexOf(list, { id: 1 }), 1);
  assert.equal(looseIndexOf(list, { id: 2 }), 2);
  assert.equal(looseIndexOf(list, { id: 3 }), -1);
}

原始种子者

匿名