{"id":14982029,"url":"https://github.com/gulpjs/resolve-options","last_synced_at":"2025-10-19T11:31:11.652Z","repository":{"id":39749307,"uuid":"93898300","full_name":"gulpjs/resolve-options","owner":"gulpjs","description":"Resolve an options object based on configuration.","archived":false,"fork":false,"pushed_at":"2023-04-06T00:42:06.000Z","size":25,"stargazers_count":9,"open_issues_count":0,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-29T15:14:38.264Z","etag":null,"topics":[],"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":"2017-06-09T21:31:28.000Z","updated_at":"2023-12-10T14:36:42.000Z","dependencies_parsed_at":"2022-09-20T14:14:10.494Z","dependency_job_id":"f162dcd8-f677-4394-8942-6a8df608912b","html_url":"https://github.com/gulpjs/resolve-options","commit_stats":{"total_commits":15,"total_committers":5,"mean_commits":3.0,"dds":0.6,"last_synced_commit":"72a31cc13cb04809c7178cb4b6e12bd2694df18f"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fresolve-options","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fresolve-options/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fresolve-options/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fresolve-options/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gulpjs","download_url":"https://codeload.github.com/gulpjs/resolve-options/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237116918,"owners_count":19258330,"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":[],"created_at":"2024-09-24T14:04:40.206Z","updated_at":"2025-10-19T11:31:11.573Z","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=\"https://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# resolve-options\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\nResolve an options object based on configuration.\n\n## Usage\n\n```js\n// This example assumes a Vinyl file\n\nvar createResolver = require('resolve-options');\n\nvar config = {\n  cwd: {\n    type: 'string',\n    default: process.cwd,\n  },\n  sourcemaps: {\n    type: 'boolean',\n    default: false,\n  },\n  since: {\n    type: ['date', 'number'],\n  },\n  read: {\n    type: 'boolean',\n  },\n};\n\nvar options = {\n  sourcemaps: true,\n  since: Date.now(),\n  read: function (file) {\n    return file.extname !== '.mp4';\n  },\n};\n\nvar resolver = createResolver(config, options);\n\nvar cwd = resolver.resolve('cwd', file);\n// cwd === process.cwd()\n\nvar sourcemaps = resolver.resolve('sourcemaps', file);\n// sourcemaps === true\n\nvar read = resolver.resolve('read', file);\n// Given .mp4, read === false\n// Given .txt, read === true\n```\n\n## API\n\n### `createResolver([config,] [options])`\n\nTakes a `config` object that describes the options to accept/resolve and an `options` object (usually passed by a user) to resolve against the `config`. Returns a `resolver` that contains a `resolve` method for realtime resolution of options.\n\nThe `config` object takes the following structure:\n\n```graphql\nconfig {\n  [optionKey] {\n    type // string, array or function\n    default // any value or function\n  }\n}\n```\n\nEach option is represented by its `optionKey` in the `config` object. It must be an object with a `type` property.\n\nThe `type` property must be a string, array or function which will be passed to the [`value-or-function`][value-or-function] module (functions will be bound to the resolver to allow for dependent options).\n\nA `default` property may also be specified as a fallback if the option isn't available or is invalid. The `default` value can be any value or a function (functions will be bound to the resolver to allow for dependent defaults). **Note:** `default` values are not type-validated by the `value-or-function` module.\n\n### `resolver.resolve(optionKey, [...arguments])`\n\nTakes an `optionKey` string and any number of `arguments` to apply if an option is a function. Returns the resolved value for the `optionKey`.\n\n### `resolver.resolveConstant(optionKey)`\n\nLike `resolve`, but only returns a value if the option is constant (not a function).\n\n## License\n\nMIT\n\n\u003c!-- prettier-ignore-start --\u003e\n[downloads-image]: https://img.shields.io/npm/dm/resolve-options.svg?style=flat-square\n[npm-url]: https://npmjs.com/package/resolve-options\n[npm-image]: https://img.shields.io/npm/v/resolve-options.svg?style=flat-square\n\n[ci-url]: https://github.com/gulpjs/resolve-options/actions?query=workflow:dev\n[ci-image]: https://img.shields.io/github/actions/workflow/status/gulpjs/resolve-options/dev.yml?branch=master\u0026style=flat-square\n\n[coveralls-url]: https://coveralls.io/r/gulpjs/resolve-options\n[coveralls-image]: https://img.shields.io/coveralls/gulpjs/resolve-options/master.svg?style=flat-square\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- prettier-ignore-start --\u003e\n[value-or-function]: https://github.com/gulpjs/value-or-function\n\u003c!-- prettier-ignore-end --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgulpjs%2Fresolve-options","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgulpjs%2Fresolve-options","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgulpjs%2Fresolve-options/lists"}