made with requirebin
Created
July 20, 2015 18:25
-
-
Save jsedlacek/4f20c5dfab0d11f532cc to your computer and use it in GitHub Desktop.
requirebin sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mailto = require('mailto-parser'); | |
document.write('mailto'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){exports.Parser=Parser=require("./parser");var p=new Parser;exports.parse=p.parse;exports.complete=p.complete;exports.format=p.format},{"./parser":3}],2:[function(require,module,exports){function parseMailTo(str,mode){var o=parseMailTo.options;if(mode===undefined)mode=o.strictMode?"strict":"loose";var m=o.parser[mode].exec(str),k=o.keys[mode],mailTo={protocol:"urn"},i=k.length;while(i--)mailTo[k[i]]=m[i]||"";mailTo[o.t.name]=[];mailTo[k[mode==="strict"?1:2]].replace(o.t.parser,function($0,$1){if($1){mailTo[o.t.name].push($1)}});mailTo[o.a.name]={};mailTo[k[mode==="strict"?3:4]].replace(o.a.parser,function($0,$1,$2){if($1){if(mailTo[o.a.name][$1]===undefined){mailTo[o.a.name][$1]=$2}else if(typeof mailTo[o.a.name][$1]==="[object Array]"){mailTo[o.a.name][$1].push($2)}else if(typeof uri[o.q.name][$1]==="string"){mailTo[o.a.name][$1]=[mailTo[o.a.name][$1],$2]}}});return mailTo}parseMailTo.options={strictMode:false,keys:{strict:["source","to","specification","attributes"],loose:["source","protocol","to","specification","attributes"]},a:{name:"attributeKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},t:{name:"addresses",parser:/(?:^|,)([^,]*)?/g},parser:{strict:/^mailto:((?:(?:(?:[^:@]*)@)(?:[^:?]*)))?((?:[^?]*)(?:\?([^]*))?)/i,loose:/^((?:[a-z][a-z]+)):((?:(?:(?:[^:@]*)@)(?:[^:?]*)))?((?:[^?]*)(?:\?([^]*))?)/i}};module.exports=parseMailTo},{}],3:[function(require,module,exports){var parseMailTo=require("./parseMailTo");function sortedAttributes(attributes){var keys=[],name,i,len,key,sorted=[];for(name in attributes){for(i=0,len=keys.length;i<len;i++){if(keys[i]>=name)break}keys.splice(i,0,name)}for(i=0,len=keys.length;i<len;i++){key=keys[i];sorted.push(key+"="+attributes[key])}if(sorted.length!==0)return sorted.join("&")}function sortedAddresses(addresses){var name,i,len,address,sorted=[];for(address in addresses){for(i=0,len=sorted.length;i<len;i++){if(sorted[i]>=address)break}sorted.splice(i,0,address)}if(sorted.length!==0)return sorted.join(",")}function isSet(value){if(value!==undefined&&value!==null)return value!=="";return false}function value(value){if(value!==undefined&&value!==null)return value;return""}function prefix(value,prefix){if(value!==undefined&&value!==null)return prefix+value;return""}function suffix(value,suffix){if(value!==undefined&&value!==null)return value+suffix;return""}function Parser(options){this.options=options}Parser.prototype.parse=function(mailtoStr,strictMode){if(strictMode===true)return parseMailTo(mailtoStr,"strict");return parseMailTo(mailtoStr)};Parser.prototype.complete=function(obj){if(typeof obj==="string")obj=this.parse(obj);if(!isSet(obj.to)&&isSet(obj.addresses))obj.to=sortedAddresses(obj.addresses);if(!isSet(obj.attributes)&&isSet(obj.attributeKey))obj.attributes=sortedAttributes(obj.attributeKey);if(!isSet(obj.specification)&&isSet(obj.attributes))obj.specification=prefix(obj.attributes,"?");return obj};Parser.prototype.format=function(obj){obj=this.complete(obj);return suffix(obj.protocol,":").toLowerCase()+value(obj.addresses).toLowerCase()+value(obj.specification)};module.exports=exports=Parser},{"./parseMailTo":2}],"mailto-parser":[function(require,module,exports){module.exports=require("./lib")},{"./lib":1}]},{},[]);var mailto=require("mailto-parser");document.write("mailto"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "requirebin-sketch", | |
"version": "1.0.0", | |
"dependencies": { | |
"mailto-parser": "1.0.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- contents of this file will be placed inside the <body> --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- contents of this file will be placed inside the <head> --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment