From 645a99fe240bb17a872bc6ede9a6cdcef2246f41 Mon Sep 17 00:00:00 2001 From: mwcz Date: Mon, 13 May 2013 11:19:05 -0400 Subject: [PATCH] add snippets for property descriptors --- snippets/javascript.snippets | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/snippets/javascript.snippets b/snippets/javascript.snippets index 2901587..801968f 100644 --- a/snippets/javascript.snippets +++ b/snippets/javascript.snippets @@ -161,3 +161,40 @@ snippet obj F.prototype = o; return new F(); } +# Define multiple properties +snippet props + var ${1:my_object} = Object.defineProperties( + ${2:new Object()}, + { + ${3:property} : { + get : function $1_$3_getter() { + // getter code + }, + set : function $1_$3_setter(value) { + // setter code + }, + value : ${4:value}, + writeable : ${5:boolean}, + enumerable : ${6:boolean}, + configurable : ${7:boolean} + } + } + ); +# Define single property +snippet prop + Object.defineProperty( + ${1:object}, + "${2:property}", + { + get : function $1_$2_getter() { + // getter code + }, + set : function $1_$2_setter(value) { + // setter code + }, + value : ${3:value}, + writeable : ${4:boolean}, + enumerable : ${5:boolean}, + configurable : ${6:boolean} + } + );