{"id":14982028,"url":"https://github.com/gulpjs/vinyl-contents","last_synced_at":"2025-10-19T11:31:18.449Z","repository":{"id":57392715,"uuid":"186146752","full_name":"gulpjs/vinyl-contents","owner":"gulpjs","description":"Utility to read the contents of a vinyl file.","archived":false,"fork":false,"pushed_at":"2023-02-28T02:53:34.000Z","size":17,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-29T15:14:39.509Z","etag":null,"topics":["gulp","gulp-plugins","gulpplugin","javascript","nodejs","streams","vinyl"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gulpjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":["gulpjs","phated","yocontra"],"tidelift":"npm/gulp","open_collective":"gulpjs"}},"created_at":"2019-05-11T15:01:26.000Z","updated_at":"2024-08-02T02:21:50.000Z","dependencies_parsed_at":"2023-01-19T16:17:12.662Z","dependency_job_id":"d784de93-13d1-453d-a2b0-97813659d6ec","html_url":"https://github.com/gulpjs/vinyl-contents","commit_stats":{"total_commits":9,"total_committers":4,"mean_commits":2.25,"dds":"0.33333333333333337","last_synced_commit":"b61b2fc2cb59809c557b3b9424d1a505353b8a96"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fvinyl-contents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fvinyl-contents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fvinyl-contents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fvinyl-contents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gulpjs","download_url":"https://codeload.github.com/gulpjs/vinyl-contents/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237116932,"owners_count":19258331,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gulp","gulp-plugins","gulpplugin","javascript","nodejs","streams","vinyl"],"created_at":"2024-09-24T14:04:40.116Z","updated_at":"2025-10-19T11:31:13.135Z","avatar_url":"https://github.com/gulpjs.png","language":"JavaScript","funding_links":["https://github.com/sponsors/gulpjs","https://github.com/sponsors/phated","https://github.com/sponsors/yocontra","https://tidelift.com/funding/github/npm/gulp","https://opencollective.com/gulpjs"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"http://gulpjs.com\"\u003e\n    \u003cimg height=\"257\" width=\"114\" src=\"https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n# vinyl-contents\n\n[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url]\n\nUtility to read the contents of a vinyl file.\n\n## Usage\n\n```js\n/*\n  WARNING: This is a very naive plugin implementation\n  It is only meant for demonstation purposes.\n  For a more complete implementation, see: https://github.com/gulp-community/gulp-pug\n*/\nvar { Transform } = require('streamx');\nvar pug = require('pug');\nvar vinylContents = require('vinyl-contents');\n\nfunction gulpPug(options) {\n  return new Transform({\n    transform: function (file, cb) {\n      vinylContents(file, function (err, contents) {\n        if (err) {\n          return cb(err);\n        }\n\n        if (!contents) {\n          return cb();\n        }\n\n        file.contents = pug.compile(contents.toString(), options)();\n        cb(null, file);\n      });\n    },\n  });\n}\n```\n\n## API\n\n### `vinylContents(file, callback)`\n\n**Warning:** Only use this if interacting with a library that can **only** receive strings or buffers. This loads all streaming contents into memory which can cause unexpected results for your end-users.\n\nTakes a Vinyl file and an error-first callback. Calls the callback with an error if one occur (or if the first argument is not a Vinyl file), or the file contents if no error occurs.\n\nIf the Vinyl contents are:\n\n- A Buffer, will be returned directly.\n- A Stream, will be buffered into a BufferList and returned.\n- Empty, will be undefined.\n\n## License\n\nMIT\n\n\u003c!-- prettier-ignore-start --\u003e\n[downloads-image]: https://img.shields.io/npm/dm/vinyl-contents.svg?style=flat-square\n[npm-url]: https://www.npmjs.com/package/vinyl-contents\n[npm-image]: https://img.shields.io/npm/v/vinyl-contents.svg?style=flat-square\n\n[ci-url]: https://github.com/gulpjs/vinyl-contents/actions?query=workflow:dev\n[ci-image]: https://img.shields.io/github/actions/workflow/status/gulpjs/vinyl-contents/dev.yml?branch=master\u0026style=flat-square\n\n[coveralls-url]: https://coveralls.io/r/gulpjs/vinyl-contents\n[coveralls-image]: https://img.shields.io/coveralls/gulpjs/vinyl-contents/master.svg?style=flat-square\n\u003c!-- prettier-ignore-end --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgulpjs%2Fvinyl-contents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgulpjs%2Fvinyl-contents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgulpjs%2Fvinyl-contents/lists"}