Skip to content

Instantly share code, notes, and snippets.

View defims's full-sized avatar

Wei Long defims

View GitHub Profile
var MultiGetSet = function(opt){
var getType = function(o) {
return ({}).toString.call(o).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
};
if(!opt.public || !opt.private)
return opt.public;
if(opt.handler && opt.handler.init)
var MultiGetSet = function(opt){
var getType = function(o) {
return ({}).toString.call(o).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
};
if(!opt.public || !opt.private)
return opt.public;
if(opt.handler && opt.handler.init)
// Polyfill for ES6 Object.observe()
// Limitations:
// - No 'splice' (etc); if you're observing an Array, you're gonna have a bad time
(function(global) {
function assert(e) { if (!e) throw new Error('Assertion failed'); }
// http://wiki.ecmascript.org/doku.php?id=harmony:observe
// ECMAScript internal approximations
<!-- modified from http://alex.dojotoolkit.org/08/jscript/lettable.html -->
<html>
<head>
<title>A Crazy Getter/Setter Hack</title>
</head>
<body>
<script language="VBScript" type="text/VBScript">
Function exec_vb_global(code)
ExecuteGlobal(code)
End Function
@defims
defims / PACKAGE.json
Last active June 13, 2016 07:18 — forked from jed/LICENSE.txt
communicate with jsonp
{
"name": "jsonp",
"keywords": ["jsonp", "AJAX", "communication", "get"],
"version": "0.1.0"
}
@defims
defims / PACKAGE.json
Last active June 13, 2016 07:16 — forked from jed/LICENSE.txt
write contextual templates
{
"name": "template",
"keywords": ["template", "HTML", "render"],
"version": "0.1.0"
}
@defims
defims / PACKAGE.json
Last active June 13, 2016 07:17 — forked from jed/LICENSE.txt
bind functions cross-browser
{
"name": "bind",
"keywords": ["bind", "function", "functional", "curry"],
"version": "0.1.0"
}
@defims
defims / PACKAGE.json
Last active June 13, 2016 07:17 — forked from jed/LICENSE.txt
map properties for arrays and objects
{
"name": "map",
"keywords": ["map", "array", "arrays", "functional"],
"version": "0.1.0"
}
@defims
defims / PACKAGE.json
Last active June 13, 2016 07:42 — forked from jed/LICENSE.txt
use cached DOM elements to escape HTML
{
"name": "escapeHTML",
"keywords": ["escape", "escaping", "HTML", "XSS"],
"version": "0.1.0"
}
@defims
defims / PACKAGE.json
Last active June 13, 2016 07:41 — forked from jed/LICENSE.txt
use anchor tags to parse URLs into components
{
"name": "parseURL",
"keywords": ["parse", "URL", "link"],
"version": "0.1.0"
}