Skip to content

Instantly share code, notes, and snippets.

@peabnuts123
Last active January 10, 2017 22:12
Show Gist options
  • Save peabnuts123/efecb513b79001eee7fd to your computer and use it in GitHub Desktop.
Save peabnuts123/efecb513b79001eee7fd to your computer and use it in GitHub Desktop.
Visual Studio CodeSnippet for JavaScript. Create a named function property on an object with various parameters
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>Object Function Property</Title>
<Author>Jeff Andrews</Author>
<Description>Creates a named function on an object</Description>
<HelpUrl>
</HelpUrl>
<Shortcut>ofunc</Shortcut>
</Header>
<Snippet>
<Declarations>
<Literal Editable="true">
<ID>objectName</ID>
<ToolTip>Variable name for which this function will be a property of</ToolTip>
<Default>object</Default>
<Function>
</Function>
</Literal>
<Literal Editable="true">
<ID>functionName</ID>
<ToolTip>Name of function to assign to this object</ToolTip>
<Default>doSomething</Default>
<Function>
</Function>
</Literal>
<Literal Editable="true">
<ID>parameters</ID>
<ToolTip>Parameters for this function</ToolTip>
<Default>id</Default>
<Function>
</Function>
</Literal>
</Declarations>
<Code Language="JavaScript">
<![CDATA[$objectName$.$functionName$ = function $functionName$($parameters$) {
};]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment