PageSourceSearch

https://gulpjs.com/assets/js/32e89020.ce469d82.js

js gulpjs.com collected 2026-09-24 07:27:53 UTC 7,129 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkgulpjs_github_io=self.webpackChunkgulpjs_github_io||[]).push([[850],{5442:(e,s,t)=>{t.r(s),t.d(s,{assets:()=>c,contentTitle:()=>d,default:()=>h,frontMatter:()=>i,metadata:()=>o,toc:()=>a});var r=t(4848),n=t(8453);const i={id:"registry",title:"registry()",hide_title:!0,sidebar_label:"registry()"},d="registry()",o={id:"api/registry",title:"registry()",description:"Allows custom registries to be plugged into the task system, which can provide shared tasks or augmented functionality.",source:"@site/docs/api/registry.md",sourceDirName:"api",slug:"/api/registry",permalink:"/docs/en/api/registry",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{id:"registry",title:"registry()",hide_title:!0,sidebar_label:"registry()"},sidebar:"docs",previous:{title:"task()",permalink:"/docs/en/api/task"},next:{title:"tree()",permalink:"/docs/en/api/tree"}},c={},a=[{value:"Usage",id:"usage",level:2},{value:"Signature",id:"signature",level:2},{value:"Parameters",id:"parameters",level:3},{value:"Returns",id:"returns",level:3},{value:"Errors",id:"errors",level:3},{value:"Incorrect parameter",id:"incorrect-parameter",level:4},{value:"Missing <code>get</code> method",id:"missing-get-method",level:4},{value:"Missing <code>set</code> method",id:"missing-set-method",level:4},{value:"Missing <code>init</code> method",id:"missing-init-method",level:4},{value:"Missing <code>tasks</code> method",id:"missing-tasks-method",level:4}];function l(e){const s={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,n.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(s.h1,{id:"registry",children:"registry()"}),"\n",(0,r.jsx)(s.p,{children:"Allows custom registries to be plugged into the task system, which can provide shared tasks or augmented functionality."}),"\n",(0,r.jsxs)(s.p,{children:[(0,r.jsx)(s.strong,{children:"Note:"})," Only tasks registered with ",(0,r.jsx)(s.code,{children:"task()"})," will be provided to the custom registry. The task functions passed directly to ",(0,r.jsx)(s.code,{children:"series()"})," or ",(0,r.jsx)(s.code,{children:"parallel()"})," will not be provided - if you need to customize the registry behavior, compose tasks with string references."]}),"\n",(0,r.jsx)(s.p,{children:"When assigning a new registry, each task from the current registry will be transferred and the current registry will be replaced with the new one. This allows for adding multiple custom registries in sequential order."}),"\n",(0,r.jsxs)(s.p,{children:["See ",(0,r.jsx)(s.a,{href:"/docs/en/advanced/creating-custom-registries",children:"Creating Custom Registries"})," for details."]}),"\n",(0,r.jsx)(s.h2,{id:"usage",children:"Usage"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-js",children:"const { registry, task, series } = require('gulp');\nconst FwdRef = require('undertaker-forward-reference');\n\nregistry(FwdRef());\n\ntask('default', series('forward-ref'));\n\ntask('forward-ref', function(cb) {\n  // body omitted\n  cb();\n});\n"})}),"\n",(0,r.jsx)(s.h2,{id:"signature",children:"Signature"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-js",children:"registry([registryInstance])\n"})}),"\n",(0,r.jsx)(s.h3,{id:"parameters",children:"Parameters"}),"\n",(0,r.jsxs)(s.table,{children:[(0,r.jsx)(s.thead,{children:(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.th,{style:{textAlign:"center"},children:"parameter"}),(0,r.jsx)(s.th,{style:{textAlign:"center"},children:"type"}),(0,r.jsx)(s.th,{children:"note"})]})}),(0,r.jsx)(s.tbody,{children:(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{style:{textAlign:"center"},children:"registryInstance"}),(0,r.jsx)(s.td,{style:{textAlign:"center"},children:"object"}),(0,r.jsx)(s.td,{children:"An instance - not the class - of a custom registry."})]})})]}),"\n",(0,r.jsx)(s.h3,{id:"returns",children:"Returns"}),"\n",(0,r.jsxs)(s.p,{children:["If a ",(0,r.jsx)(s.code,{children:"registryInstance"})," is passed, nothing will be returned. If no arguments are passed, returns the current registry instance."]}),"\n",(0,r.jsx)(s.h3,{id:"errors",children:"Errors"}),"\n",(0,r.jsx)(s.h4,{id:"incorrect-parameter",children:"Incorrect parameter"}),"\n",(0,r.jsxs)(s.p,{children:["When a constructor (instead of an instance) is passed as ",(0,r.jsx)(s.code,{children:"registryInstance"}),", throws an error with the message:"]}),"\n",(0,r.jsxs)(s.blockquote,{children:["\n",(0,r.jsx)(s.p,{children:"Custom registries must be instantiated, but it looks like you passed a constructor."}),"\n"]}),"\n",(0,r.jsxs)(s.h4,{id:"missing-get-method",children:["Missing ",(0,r.jsx)(s.code,{children:"get"})," method"]}),"\n",(0,r.jsxs)(s.p,{children:["When a registry without a ",(0,r.jsx)(s.code,{children:"get"})," method is passed as ",(0,r.jsx)(s.code,{children:"registryInstance"}),", throws an error with the message:"]}),"\n",(0,r.jsxs)(s.blockquote,{children:["\n",(0,r.jsxs)(s.p,{children:["Custom registry must have ",(0,r.jsx)(s.code,{children:"get"})," function."]}),"\n"]}),"\n",(0,r.jsxs)(s.h4,{id:"missing-set-method",children:["Missing ",(0,r.jsx)(s.code,{children:"set"})," method"]}),"\n",(0,r.jsxs)(s.p,{children:["When a registry without a ",(0,r.jsx)(s.code,{children:"set"})," method is passed as ",(0,r.jsx)(s.code,{children:"registryInstance"}),", throws an error with the message:"]}),"\n",(0,r.jsxs)(s.blockquote,{children:["\n",(0,r.jsxs)(s.p,{children:["Custom registry must have ",(0,r.jsx)(s.code,{children:"set"})," function."]}),"\n"]}),"\n",(0,r.jsxs)(s.h4,{id:"missing-init-method",children:["Missing ",(0,r.jsx)(s.code,{children:"init"})," method"]}),"\n",(0,r.jsxs)(s.p,{children:["When a registry without an ",(0,r.jsx)(s.code,{children:"init"})," method is passed as ",(0,r.jsx)(s.code,{children:"registryInstance"}),", throws an error with the message:"]}),"\n",(0,r.jsxs)(s.blockquote,{children:["\n",(0,r.jsxs)(s.p,{children:["Custom registry must have ",(0,r.jsx)(s.code,{children:"init"}),' function"']}),"\n"]}),"\n",(0,r.jsxs)(s.h4,{id:"missing-tasks-method",children:["Missing ",(0,r.jsx)(s.code,{children:"tasks"})," method"]}),"\n",(0,r.jsxs)(s.p,{children:["When a registry without a ",(0,r.jsx)(s.code,{children:"tasks"})," method is passed as ",(0,r.jsx)(s.code,{children:"registryInstance"}),", throws an error with the message:"]}),"\n",(0,r.jsxs)(s.blockquote,{children:["\n",(0,r.jsxs)(s.p,{children:["Custom registry must have ",(0,r.jsx)(s.code,{children:"tasks"})," function."]}),"\n"]})]})}function h(e={}){const{wrapper:s}={...(0,n.R)(),...e.components};return s?(0,r.jsx)(s,{...e,children:(0,r.jsx)(l,{...e})}):l(e)}},8453:(e,s,t)=>{t.d(s,{R:()=>d,x:()=>o});var r=t(6540);const n={},i=r.createContext(n);function d(e){const s=r.useContext(i);return r.useMemo((function(){return"function"==typeof e?e(s):{...s,...e}}),[s,e])}function o(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(n):e.components||n:d(e.components),r.createElement(i.Provider,{value:s},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.