{"id":49288,"library":"schema-pop","title":"schema-pop","description":"schema-pop is a JavaScript library for populating data structures based on a schema definition. Current stable version is 0.1.42, with active development and frequent minor releases. It differentiates from similar tools by focusing on schema-driven data generation for testing and prototyping, offering a simple API and support for nested objects and arrays. This library is lightweight, has no external runtime dependencies, and is published as both ESM and CommonJS modules, with TypeScript type definitions included.","status":"active","version":"0.1.42","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install schema-pop","lang":"bash","label":"npm"},{"cmd":"yarn add schema-pop","lang":"bash","label":"yarn"},{"cmd":"pnpm add schema-pop","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export not available; use named import. In CommonJS, use const { populate } = require('schema-pop').","wrong":"const populate = require('schema-pop')","symbol":"populate","correct":"import { populate } from 'schema-pop'"},{"note":"This is a named export for the class. ESM-only symbols require named import syntax.","wrong":"const SchemaPop = require('schema-pop').SchemaPop","symbol":"SchemaPop","correct":"import { SchemaPop } from 'schema-pop'"},{"note":"TypeScript users should import types with 'import type' to avoid runtime bundling issues. In CommonJS, you cannot import types directly.","wrong":"const { Schema } = require('schema-pop')","symbol":"types","correct":"import type { Schema } from 'schema-pop'"}],"quickstart":{"code":"import { populate } from 'schema-pop';\n\nconst schema = {\n  name: 'string',\n  age: 'number',\n  address: {\n    street: 'string',\n    city: 'string'\n  },\n  tags: ['string']\n};\n\nconst data = populate(schema, { name: 'John' });\nconsole.log(data);\n// Example output:\n// {\n//   name: 'John',\n//   age: 27,\n//   address: { street: 'abc', city: 'xyz' },\n//   tags: ['abc', 'def']\n// }","lang":"typescript","description":"Demonstrates basic usage of populate() with a schema including strings, numbers, nested objects, and arrays. Overrides specific fields with provided values."},"warnings":[{"fix":"If you need stable order, sort the array after population or upgrade to version 0.2.0+","message":"In version 0.1.0, the output order of array elements is not guaranteed to be stable. Do not rely on array ordering.","severity":"breaking","affected_versions":"<0.2.0"},{"fix":"Define a type for your schema and cast the result: const data = populate<MyType>(schema);","message":"When using TypeScript, type inference may not work correctly with complex nested schemas. Use explicit type annotations.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Replace `generate(schema)` with `populate(schema)`.","message":"The method `generate` is deprecated in favor of `populate` since version 0.1.20.","severity":"deprecated","affected_versions":">=0.1.20 <0.2.0"},{"fix":"Seed the random number generator if supported, or use your own deterministic generation.","message":"Populate generates random data each time. For reproducible tests, you cannot rely on constant output.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.1.42':24 'activ':26 'api':52 'array':59 'base':15 'commonj':76 'current':20 'data':13,43 'definit':19,81 'depend':68 'develop':27 'differenti':33 'driven':42 'esm':74 'extern':66 'focus':38 'frequent':29 'generat':44 'includ':82 'javascript':9,83 'librari':10,61 'lightweight':63 'minor':30 'modul':77 'nest':56 'object':57 'offer':49 'pop':3,6 'popul':12 'prototyp':48 'publish':71 'releas':31 'runtim':67 'schema':2,5,18,41 'schema-driven':40 'schema-pop':1,4 'similar':35 'simpl':51 'stabl':21 'structur':14 'support':54 'test':46 'tool':36 'type':80 'typescript':79 'version':22","created_at":"2026-06-07T17:01:00.226605+00:00","updated_at":"2026-06-07T17:01:00.226605+00:00","problems":[{"fix":"Use named import: import { populate } from 'schema-pop'","cause":"Using default import instead of named import: import populate from 'schema-pop'","error":"TypeError: populate is not a function"},{"fix":"Install package: npm install schema-pop","cause":"Package not installed or module resolution issue","error":"Cannot find module 'schema-pop'"},{"fix":"Ensure schema is a plain object or array describing types","cause":"Passing an invalid schema (e.g., string or number) to populate","error":"Schema must be an object or array"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"schema-pop","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}