Skip to content

Instantly share code, notes, and snippets.

@rodu
Created September 19, 2016 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodu/0b089351c69df8fa4e566bbd82143ad9 to your computer and use it in GitHub Desktop.
Save rodu/0b089351c69df8fa4e566bbd82143ad9 to your computer and use it in GitHub Desktop.
{
"proto": {
"prefix": "proto",
"body": "${1:class_name}.prototype.${2:method_name} = function ${2:method_name}(${3:first_argument}){\n\t${0:// body...}\n};\n",
"description": "Prototype"
},
"befinj": {
"prefix": "befinj",
"body": "beforeEach(inject((${1:name}) => {\n ${2:}\n}));",
"description": "beforeEach inject"
},
"befprov": {
"prefix": "befprov",
"body": "beforeEach(module(($provide) => {\n $provide.value('${1:name}', ${2:value});\n}));\n",
"description": "beforeEach provide"
},
"angcon": {
"prefix": "angcon",
"body": "/**\n* @ngdoc object\n* @name ${1:moduleName}.object:${2:constantName}\n* @description\n* Description of the ${2:constantName} constant service.\n*/\nangular.module('${1:moduleName}').constant('${2:constantName}', '${3:}');\n",
"description": "Angular Constant"
},
"angcont": {
"prefix": "angcont",
"body": "/**\n* @ngdoc controller\n* @name ${1:moduleName}.controller:${2:controllerName}\n* @description\n* Description of the ${2:controllerName} controller.\n*/\nangular.module('${1:moduleName}').controller('${2:controllerName}', [\n function ${2:controllerName}(){\n 'use strict';\n\n }\n]);",
"description": "Angular Controller"
},
"angdir": {
"prefix": "angdir",
"body": "/**\n* @ngdoc directive\n* @name ${1:moduleName}.directive:${2:directiveName}\n* @description\n* Description of the ${2:directiveName} directive.\n*/\nangular.module('${1:moduleName}').directive('${2:directiveName}', [\n function ${2:directiveName}(){\n 'use strict';\n\n var\n scope = {};\n\n function link ($scope, $element) {\n ${3://body}\n }\n\n return {\n restrict: 'A',\n scope: scope,\n link: link\n };\n }\n]);",
"description": "Angular Directive"
},
"angfac": {
"prefix": "angfac",
"body": "/**\n* @ngdoc service\n* @name ${1:moduleName}.service:${2:serviceName}\n* @description\n* Description of the ${2:serviceName} service.\n*/\nangular.module('${1:moduleName}').factory('${2:serviceName}', [\n function ${2:serviceName}(){\n 'use strict';\n\n function ${3:api}(){\n // ${4:body}\n }\n\n return {\n ${3:api}: ${3:api}\n };\n }\n]);",
"description": "Angular Factory"
},
"iman": {
"prefix": "iman",
"body": "import angular from 'angular';",
"description": "import angular"
},
"angmod": {
"prefix": "angmod",
"body": "/**\n* @ngdoc overview\n* @name ${1:moduleName}\n* @description\n* Description of the ${1:moduleName} module.\n*/\nangular.module('${1:moduleName}', [${2:}]);\n",
"description": "Angular Module"
},
"scodes": {
"prefix": "scodes",
"body": "$scope.$on('$destroy', ${1:function(){\n ${2:// body}\n\\}});",
"description": "(Rodu) On Scope destroy"
},
"tescon": {
"prefix": "tescon",
"body": "describe('Controller ${1:ControllerName}:', () => {\n\n let $controller;\n let $scope;\n\n beforeEach(module('${2:moduleName}'));\n\n beforeEach(inject(($rootScope, _$controller_) => {\n $controller = _$controller_;\n $scope = $rootScope.$new();\n }));\n\n describe('When ${3:}:', () => {\n it('should ${4:}', () => {\n $controller('${1:ControllerName}', { $scope });\n\n ${5:}\n });\n });\n});\n",
"description": "Test Angular Controller"
},
"tesdir": {
"prefix": "tesdir",
"body": "describe('Directive ${1:directiveName}:', () => {\n\n beforeEach(module('${2:moduleName}'));\n\n // The element on which we attach the dashboardPanel directive\n const ELEMENT_HTML = '<div ${3:directive-name}></div>';\n\n let $rootScope;\n let $compile;\n\n function initScope($scope){\n const $directiveScope = $scope || $rootScope.$new();\n const $element = $compile(ELEMENT_HTML)($directiveScope);\n\n $directiveScope.$digest();\n\n // Access the directive scope object\n return $element.isolateScope();\n }\n\n beforeEach(() => {\n\n inject(['$rootScope', '$compile', (_$rootScope_, _$compile_) => {\n $rootScope = _$rootScope_;\n $compile = _$compile_;\n }]);\n\n });\n\n describe('When ${4:}:', () => {\n it('should ${5:}', () => {\n ${6:}\n initScope();\n\n });\n });\n});\n",
"description": "Test Angular Directive"
},
"tesser": {
"prefix": "tesser",
"body": "describe('Service ${1:serviceName}:', () => {\n\n let ${1:serviceName};\n\n beforeEach(module('${2:moduleName}'));\n\n beforeEach(inject((_${1:serviceName}_) => {\n ${1:serviceName} = _${1:serviceName}_;\n }));\n\n describe('When ${3:}:', () => {\n it('should ${4:}', () => {\n ${5:}\n });\n });\n});\n",
"description": "Test Angular Service"
},
"angval": {
"prefix": "angval",
"body": "/**\n* @ngdoc object\n* @name ${1:moduleName}.object:${2:valueName}\n* @description\n* Description of the ${2:valueName} value service.\n*/\nangular.module('${1:moduleName}').value('${2:valueName}', '${3:}');\n",
"description": "Angular Value"
},
"arrmaes": {
"prefix": "arrmaes",
"body": "map((${1:arguments}) => {\n ${4:// body}\n}${2:,})${3:;}",
"description": "Array map ES6"
},
"co": {
"prefix": "co",
"body": "console.log(${1:something});",
"description": "console log"
},
"deb": {
"prefix": "deb",
"body": "debug('${1:something}');",
"description": "debug"
},
"defbou": {
"prefix": "defbou",
"body": "\n define([\"jquery\"], function($){\n \"use strict\";\n \n function initialise($component) {\n ${0}\n }\n\n return {\n \"initialise\": initialise\n };\n});\n",
"description": "RequireJS Bound Module Define"
},
"def": {
"prefix": "def",
"body": "\n define([${1:'jquery'}], function(${2:$}){\n 'use strict';\n\n ${3:$TM_SELECTED_TEXT}\n});",
"description": "RequireJS define"
},
"meth": {
"prefix": "meth",
"body": "${1:name}(${2:arguments}) {\n ${3:// body}\n}",
"description": "(Rodu) ES6 Method"
},
"funes": {
"prefix": "funes",
"body": "(${1:arguments}) => {\n ${3:// body}\n}${2:;}",
"description": "Inline Function ES6"
},
"func": {
"prefix": "func",
"body": "function (${1:arguments}) {\n ${3:// body}\n}${2:;}",
"description": "Inline Function"
},
"ifun": {
"prefix": "ifun",
"body": "(function ${1:myFn}(${2:arguments}){\n\t${0:// body}\n}(${2:arguments}));",
"description": "Function"
},
"con": {
"prefix": "con",
"body": "<%= ${0:config.} %>",
"description": "Grunt variable"
},
"impo": {
"prefix": "impo",
"body": "import {${1:value}} from '${2:module}';",
"description": "(Rodu) Import ES6"
},
"req": {
"prefix": "req",
"body": "let ${1:module} = require('${2:}${1:module}');\n",
"description": "(Rodu) Node Require ES6"
},
"ret": {
"prefix": "ret",
"body": "\n return {\n ${0}\n};",
"description": "return object"
},
"use": {
"prefix": "use",
"body": "'use strict';",
"description": "use strict"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment