CodeSampleX

Пример

sqids 0.3.0: defaultOptions

Проверенный пример — npm sqids 0.3.0: defaultOptions. Контракт выполнен на node 22 · linux debian/x64 · docker и пройден: assert sqids.defaultOptions…

sha256:71e0740659c7b32a235fe5bbc109713e1e25aa259893f1a900d359dacc83fb6c

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. MIT-0

Свидетельства выполнения

Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.

Основа свидетельства
Подписанный контракт пройден
Квитанции проверки
1
Ключи подписи, собравшие его
1
Заявленная среда node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Среды запусков проверки

Окружение Контракт Этапы Запуск
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-15

Кейс

HOW
Цель
verify sqids.defaultOptions in pkg:npm/sqids@0.3.0
Пакеты
Символы
  • sqids.defaultOptions
Окружение
node 22.23.2
Создан
2026-09-15T21:05:56Z

Контракт

  1. assert sqids.defaultOptions provides default alphabet, minLength, and blocklist
  2. assert sqids.defaultOptions alphabet contains 62 unique alphanumeric characters
  3. assert sqids.defaultOptions minLength equals 0
  4. assert sqids.defaultOptions blocklist is a Set containing default blocked words
  5. assert Sqids uses defaultOptions properties when initialized without configuration
  6. assert Sqids allows overriding individual defaultOptions properties

Файлы

  • PROMPT.md
  • csx.json
  • index.js
  • 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 sqids.defaultOptions in pkg:npm/sqids@0.3.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/sqids@0.3.0
Demonstrate these symbols/APIs:
  - sqids.defaultOptions

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:ea0b5f4127b189fd9dd87a74bf3a16c3becfc24815ccfa94552cea3aed703943","contract":["assert sqids.defaultOptions provides default alphabet, minLength, and blocklist","assert sqids.defaultOptions alphabet contains 62 unique alphanumeric characters","assert sqids.defaultOptions minLength equals 0","assert sqids.defaultOptions blocklist is a Set containing default blocked words","assert Sqids uses defaultOptions properties when initialized without configuration","assert Sqids allows overriding individual defaultOptions properties"],"goal":"verify sqids.defaultOptions in pkg:npm/sqids@0.3.0","kind":"HOW","packages":["pkg:npm/sqids@0.3.0"],"schemaVersion":1,"symbols":["sqids.defaultOptions"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/sqids@0.3.0"],"schemaVersion":1,"subject":"pkg:npm/sqids@0.3.0","symbols":["sqids.defaultOptions"],"verifierAdapter":"node-typescript@1"}
index.js
const sqidsModule = require('sqids');
const Sqids = sqidsModule.default || sqidsModule;
const defaultOptions = sqidsModule.defaultOptions || Sqids.defaultOptions;

/**
 * Returns the default configuration options for Sqids.
 *
 * @returns {{ alphabet: string, minLength: number, blocklist: Set<string> }} The default options object.
 */
function getDefaultOptions() {
  return defaultOptions;
}

/**
 * Creates a new Sqids instance with optional configuration overrides.
 *
 * @param {Object} [options] - Configuration overrides.
 * @returns {Sqids} A new Sqids instance.
 */
function createSqidsWithDefaults(options) {
  return new Sqids(options);
}

module.exports = {
  getDefaultOptions,
  createSqidsWithDefaults,
  defaultOptions,
  Sqids,
};
package-lock.json
{
  "name": "sample-sqids-defaultoptions",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-sqids-defaultoptions",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "sqids": "0.3.0"
      }
    },
    "node_modules/sqids": {
      "version": "0.3.0",
      "resolved": "https://registry.npmjs.org/sqids/-/sqids-0.3.0.tgz",
      "integrity": "sha512-lOQK1ucVg+W6n3FhRwwSeUijxe93b51Bfz5PMRMihVf1iVkl82ePQG7V5vwrhzB11v0NtsR25PSZRGiSomJaJw==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-sqids-defaultoptions",
  "version": "1.0.0",
  "description": "Clean-room sample verifying sqids.defaultOptions in pkg:npm/sqids@0.3.0",
  "main": "index.js",
  "license": "MIT-0",
  "dependencies": {
    "sqids": "0.3.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify sqids.defaultOptions in pkg:npm/sqids@0.3.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/sqids@0.3.0"
  ],
  "symbols": [
    "sqids.defaultOptions"
  ]
}
test/contract.mjs
import assert from 'node:assert';
import Sqids, { defaultOptions } from 'sqids';
import { getDefaultOptions, createSqidsWithDefaults } from '../index.js';

// 1. defaultOptions provides default alphabet, minLength, and blocklist
assert.ok(defaultOptions, 'defaultOptions must be defined');
assert.strictEqual(typeof defaultOptions, 'object', 'defaultOptions must be an object');
assert.deepStrictEqual(
  getDefaultOptions(),
  defaultOptions,
  'helper getDefaultOptions() must return the same defaultOptions'
);

// 2. Alphabet property contains 62 unique alphanumeric characters
assert.strictEqual(typeof defaultOptions.alphabet, 'string', 'alphabet must be a string');
assert.strictEqual(defaultOptions.alphabet.length, 62, 'alphabet length must be 62');
assert.strictEqual(
  defaultOptions.alphabet,
  'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
  'alphabet must match standard 62-character alphanumeric set'
);
assert.strictEqual(
  new Set(defaultOptions.alphabet).size,
  62,
  'alphabet must have 62 unique characters'
);

// 3. minLength property equals 0
assert.strictEqual(typeof defaultOptions.minLength, 'number', 'minLength must be a number');
assert.strictEqual(defaultOptions.minLength, 0, 'default minLength must be 0');

// 4. blocklist property is a Set containing default blocked words
assert.ok(defaultOptions.blocklist instanceof Set, 'blocklist must be an instance of Set');
assert.ok(defaultOptions.blocklist.size > 0, 'blocklist must not be empty');
assert.strictEqual(defaultOptions.blocklist.size, 560, 'default blocklist contains 560 blocked words');
assert.ok(defaultOptions.blocklist.has('anal'), 'blocklist should contain standard blocked words');
assert.ok(defaultOptions.blocklist.has('bitch'), 'blocklist should contain standard blocked words');

// 5. Sqids uses defaultOptions properties when initialized without configuration
const defaultSqids = new Sqids();
const encodedWithDefaults = defaultSqids.encode([1, 2, 3]);
assert.strictEqual(typeof encodedWithDefaults, 'string', 'encode with defaults returns string');
assert.strictEqual(encodedWithDefaults, '86Rf07', 'encoding [1, 2, 3] with default options yields 86Rf07');
assert.deepStrictEqual(
  defaultSqids.decode(encodedWithDefaults),
  [1, 2, 3],
  'decode should restore [1, 2, 3]'
);

// 6. Overriding individual defaultOptions properties
const helperSqids = createSqidsWithDefaults({ minLength: 8 });
const encodedMin = helperSqids.encode([1, 2, 3]);
assert.ok(encodedMin.length >= 8, 'custom minLength override must be respected');
assert.deepStrictEqual(
  helperSqids.decode(encodedMin),
  [1, 2, 3],
  'decode should restore [1, 2, 3] with custom minLength'
);

console.log('All contract assertions passed.');

Исходный сидер

аноним