{"name":"yamlify-object","version":"3.0.0-beta","keywords":["formatter","console","log","yaml","beauty","stringify","yamlify"],"author":{"url":"http://github.com/eugeny-dementev","name":"Eugeny Dementev"},"license":"MIT","_id":"yamlify-object@3.0.0-beta","maintainers":[{"name":"eugeny-dementev","email":"eugeny.dementev@ya.ru"}],"homepage":"https://github.com/eugeny-dementev/yamlify-object","bugs":{"url":"https://github.com/eugeny-dementev/yamlify-object/issues"},"dist":{"shasum":"23fbce7f3b6806d54ce150f1add4dbf8c46de996","tarball":"http://registry-npm.ywwl.com/yamlify-object/download/yamlify-object-3.0.0-beta.tgz","fileCount":49,"integrity":"sha512-VdNzlx++aYbRbONP5SzjRc5nonMSlMf4FwORuTRtv+NtgnaRpFHUSF51bWAxmof6C0ybWpzga+OQVUJgRl4cAQ==","signatures":[{"sig":"MEYCIQCnM9GFCrlQYdUwD9ZAlt3z8aW0RzQrS6Rsvnwy7KSLOQIhAMiixaLgCxcHBTiUA01pctHNPNqjP5LnAz1x7Oju2LoD","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":52129,"size":12546,"noattachment":false,"key":"/yamlify-object/-/yamlify-object-3.0.0-beta.tgz"},"main":"./dist/cjs/index.js","types":"./dist/types/index.d.ts","module":"./dist/esm/index.js","engines":{"node":">=4.0.0"},"exports":{".":{"types":"./dist/types/index.d.ts","import":"./dist/esm/index.js","require":"./dist/cjs/index.js"}},"gitHead":"2a43f2b9b94ffd779e7b2969489b09ba01f5d769","scripts":{"lint":"eslint ./src","test":"jest test","build":"npm run build:types && npm run build:esm && npm run build:cjs && npm run build:umd && npm run build:packages","lint-fix":"eslint ./src --fix","build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json","build:umd":"webpack","prepublish":"npm run lint && npm test && npm run build","build:types":"tsc -p tsconfig.types.json","build:packages":"node scripts/write-subpackage-json.cjs"},"_npmUser":{"name":"eugeny-dementev","email":"eugeny.dementev@ya.ru"},"repository":{"url":"git+https://github.com/eugeny-dementev/yamlify-object.git","type":"git"},"_npmVersion":"11.6.2","description":"Stringify object/array with yaml syntax","directories":{},"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^28.0.0","eslint":"^8.23.0","ts-jest":"^28.0.8","ts-node":"^10.9.1","webpack":"^5.74.0","ts-loader":"^9.3.1","typescript":"4.7.4","@types/jest":"^28.1.8","webpack-cli":"^4.10.0","@typescript-eslint/parser":"^5.35.1","@typescript-eslint/eslint-plugin":"^5.35.1"},"_npmOperationalInternal":{"tmp":"tmp/yamlify-object_3.0.0-beta_1767440801589_0.7598637380394151","host":"s3://npm-registry-packages-npm-production"},"readme":"# yamlify-object\n\nStringify object/array with yaml syntax\n\n## Install\n\n```\nnpm install yamlify-object\n```\n\n## Usage\n\n```ts\nimport yamlifyObject from 'yamlify-object';\n\nconst obj = {\n  array: [\n    2,\n    'two',\n    {\n      emptyArray: [],\n    },\n  ],\n  error: new Error('message'),\n  date: new Date(0),\n  object: {\n    number: 200,\n    bool: false,\n    null: null,\n    undefined: undefined,\n    emptyObject: {},\n  },\n};\n\nobj.circular = obj;\n\nconst formattedString = yamlifyObject(obj, {\n  indent: '  ',\n  prefix: '\\n',\n  postfix: '\\n',\n});\n\nconsole.log(formattedString);\n/*\n\n  array:\n    - 2\n    - two\n    - emptyArray: []\n  error: Error: message\n  date: new Date(1970-01-01T00:00:00.000Z)\n  object:\n    number: 200\n    bool: false\n    null: null\n    undefined: undefined\n    emptyObject: {}\n  circular: [Circular]\n\n*/\n```\n## API\n\n### yamlifyObject(input, [options])\n\n#### input\n\nType: `Object` `Array`\n\n#### options\n\n##### indent\n\nType: `string`<br>\nDefault: `' '` - single space\n\n##### prefix\n\nType: `string`<br>\nDefault: `'\\n'`\n\n##### postfix\n\nType: `string`<br>\nDefault: `''`\n\n##### dateToString(date: Date)\n\nType: `Function`\n\nExpected to return a `string` that stringified version of Date instance.\n\n##### errorToString(error: Error)\n\nType: `Function`\n\nExpected to return a `string` that stringified version of Error instance.\n\n##### colors\n\nType: `object`<br>\nDefault:\n``` ts\n{\n  date: function (s: string): string,\n  error: function (s: string): string,\n  symbol: function (s: string): string,\n  string: function (s: string): string,\n  number: function (s: string): string,\n  boolean: function (s: string): string,\n  null: function (s: string): string,\n  undefined: function (s: string): string,\n}\n```\n\nEach property of colors object expected to be a `function` that\nexpected to return somehow colorified version of passed `string` argument.\n\nYou can specify colors only for types you need and, if have the need, the base text color.\nThe rest will stay colorless strings:\n\n``` js\nconst obj = {\n  number: 1\n  string: 'str',\n  bool: true,\n};\n\nconst formattedString = yamlifyObject(obj, {\n  colors: {\n    base: (text) => `COLOR_CODE${text}COLOR_CODE`,\n    number: (value) => `COLOR_CODE${value}COLOR_CODE`,\n    boolean: (value) => `COLOR_CODE${value}COLOR_CODE`,\n  },\n});\n\nconsole.log(formattedString);\n/*\n number: COLOR_CODE1COLOR_CODE\n string: str\n bool: COLOR_CODEtrueCOLOR_CODE\n*/\n```\n\n`base` color is the text that is not related to the values (names of the properties, dashes, brackets, etc)\n\n\nFor terminal can be used [yamlify-object-colors](https://github.com/eugeny-dementev/yamlify-object-colors) preset: \n\n![Object formating example](https://raw.githubusercontent.com/eugeny-dementev/yamlify-object-colors/master/terminal.png \"Object formating example\")\n\n[travis-img]: https://travis-ci.org/eugeny-dementev/yamlify-object.svg?branch=master\n[travis-url]: https://travis-ci.org/eugeny-dementev/yamlify-object\n\n[codecov-img]: https://codecov.io/github/eugeny-dementev/yamlify-object/coverage.svg?branch=master\n[codecov-url]: https://codecov.io/github/eugeny-dementev/yamlify-object?branch=master\n","publish_time":1767440801749,"_cnpm_publish_time":1767440801749,"dist-tags":{"beta":"3.0.0-beta","latest":"3.0.0"}}