Skip to content

Instantly share code, notes, and snippets.

@godDLL
Last active August 28, 2016 07:44
Show Gist options
  • Save godDLL/ee5d2e73d491d7c0d68bef130788b0f3 to your computer and use it in GitHub Desktop.
Save godDLL/ee5d2e73d491d7c0d68bef130788b0f3 to your computer and use it in GitHub Desktop.
short ES2015 function class
(function(w){"use strict";var a=Object.assign=Object.assign||function assign(t){var i=0,s,key;while(s=arguments[i++])for(k in s)if(s.hasOwnProperty(k))t[k]=s[k];return t};w.ass=function(t,s){a(t.p,s);return t}})(window)
// short ES2015 function class
(function (root, factory){
'use strict'
if ('function' == typeof define && define.amd){
define([], factory)
} else if ('object' == typeof module && module.exports){
module.exports= factory()
} else
root.ass= factory()
}(this, function (){
Object.assign= Object.assign || function assign (target){
var i= 0, src, key
while (src= arguments[i++])
for (key in src)
if (src.hasOwnProperty(key))
target[key]= src[key]
return target
}
return function (type, share){
Object.assign( type.prototype, share)
return type
}
}))
{
"name": "ass.js",
"version": "0.0.0",
"description": "short ES2015 function class",
"license": "MIT",
"keywords": [
"class",
"ES6"
],
"main": "ass.js"
}
@godDLL
Copy link
Author

godDLL commented Aug 28, 2016

> var T= ass(function (a){
...     this.x= a
... }, {
...     y:function (){ return this.x }
... })
undefined
> var t= new T(1)
undefined
> t.y()
1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment