diff --git a/.travis.yml b/.travis.yml index 9c04948..d4c7860 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,10 +12,9 @@ addons: language: node_js node_js: - - "6" - "8" - "10" - - "11" + - "12" install: - PATH="`npm bin`:`npm bin -g`:$PATH" diff --git a/appveyor.yml b/appveyor.yml index e29f913..3773169 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,10 +6,9 @@ environment: MSVS_VERSION: 2013 # Test against these versions of Node.js and io.js matrix: - - nodejs_version: "6" - nodejs_version: "8" - nodejs_version: "10" - - nodejs_version: "11" + - nodejs_version: "12" platform: - x86 diff --git a/docs/compile.js b/docs/compile.js deleted file mode 100644 index 89daed6..0000000 --- a/docs/compile.js +++ /dev/null @@ -1,153 +0,0 @@ - -/** - * Module dependencies. - */ - -var fs = require('fs') -var dox = require('dox') -var jade = require('jade') -var marked = require('marked') -var hljs = require('highlight.js') -var assert = require('assert') - -fs.readFile(__dirname + '/../lib/ref.js', 'utf8', function (err, data) { - if (err) throw err - - // don't depend on dox for parsing the Markdown (raw: true) - var docs = dox.parseComments(data, { raw: true }) - var base = 0 - var sections = [] - docs.forEach(function (doc, i) { - doc.tags.forEach(function (t) { - if (t.type === 'section') { - sections.push(docs.slice(base, i)) - base = i - } - if (t.type === 'name') { - doc.name = t.string - } - if (t.type === 'type') { - doc.type = t.types[0] - } - }) - if (!doc.name) { - doc.name = doc.ctx && doc.ctx.name - } - if (!doc.type) { - doc.type = doc.ctx && doc.ctx.type || 'property' - } - }) - sections.push(docs.slice(base)) - assert.equal(sections.length, 3) - - // get the 3 sections - var exports = sections[0] - var types = sections[1] - var extensions = sections[2] - - // move NULL_POINTER from "types" to "exports" - var null_pointer = types.pop() - assert.equal(null_pointer.name, 'NULL_POINTER') - exports.push(null_pointer) - - // extract the "return" and "param" types - exports.forEach(function (doc) { - doc.tags.forEach(function (t) { - if (t.description) { - // parse the Markdown descriptions - t.description = markdown(t.description).trim() - // remove the surrounding

tags - t.description = t.description.substring(3, t.description.length - 4) - } - }) - doc.returnType = doc.tags.filter(function (t) { - return t.type == 'return' - })[0] - doc.paramTypes = doc.tags.filter(function (t) { - return t.type == 'param' - }) - }) - - // sort - exports = exports.sort(sort) - extensions = extensions.sort(sort) - - // parse and highlight the Markdown descriptions - ;[exports, types, extensions].forEach(function (docs) { - docs.forEach(function (doc) { - var desc = doc.description - desc.full = markdown(desc.full) - desc.summary = markdown(desc.summary) - desc.body = markdown(desc.body) - }) - }) - - // get a reference to the ref export doc object for every Buffer extension doc - extensions.forEach(function (doc) { - doc.ref = exports.filter(function (ref) { - return ref.name === doc.name - })[0] - }) - - fs.readFile(__dirname + '/index.jade', 'utf8', function (err, template) { - if (err) throw err - - template = jade.compile(template) - var html = template({ - exports: sections[0] - , types: sections[1] - , extensions: sections[2] - , package: require('../package.json') - , markdown: markdown - , highlight: highlight - }) - - fs.writeFile(__dirname + '/index.html', html, function (err) { - if (err) throw err - }) - }) -}) - - -/** - * Sorts an array of dox objects by doc.name. If the first letter is an '_' then - * it is considered "private" and gets sorted at the bottom. - */ - -function sort (a, b) { - var aname = a.name - var bname = b.name - var aprivate = a.isPrivate - var bprivate = b.isPrivate - if (aprivate && !bprivate) { - return 1 - } - if (bprivate && !aprivate) { - return -1 - } - return aname > bname ? 1 : -1 -} - -/** - * Parses Markdown into highlighted HTML. - */ - -function markdown (code) { - if (!code) return code - return marked(code, { - gfm: true - , highlight: highlight - }) -} - -/** - * Add syntax highlighting HTML to the given `code` block. - * `lang` defaults to "javascript" if no valid name is given. - */ - -function highlight (code, lang) { - if (!hljs.LANGUAGES.hasOwnProperty(lang)) { - lang = 'javascript' - } - return hljs.highlight(lang, code).value -} diff --git a/docs/gh-pages.sh b/docs/gh-pages.sh deleted file mode 100755 index 6a7a97c..0000000 --- a/docs/gh-pages.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -DIR=`dirname $0` -TMP_DOC_DIR="/tmp/ref_docs" - -npm run docs \ - && rm -rf $TMP_DOC_DIR \ - && mkdir -p $TMP_DOC_DIR \ - && cp -Lrf {"$DIR/index.html","$DIR/images","$DIR/scripts","$DIR/stylesheets"} $TMP_DOC_DIR \ - && git checkout gh-pages \ - && cp -Lrf $TMP_DOC_DIR/* . \ - && echo "done" diff --git a/docs/images/apple-touch-icon-114x114.png b/docs/images/apple-touch-icon-114x114.png deleted file mode 100644 index 8003885..0000000 Binary files a/docs/images/apple-touch-icon-114x114.png and /dev/null differ diff --git a/docs/images/apple-touch-icon-72x72.png b/docs/images/apple-touch-icon-72x72.png deleted file mode 100644 index a055a15..0000000 Binary files a/docs/images/apple-touch-icon-72x72.png and /dev/null differ diff --git a/docs/images/apple-touch-icon.png b/docs/images/apple-touch-icon.png deleted file mode 100644 index 40cffed..0000000 Binary files a/docs/images/apple-touch-icon.png and /dev/null differ diff --git a/docs/images/favicon.ico b/docs/images/favicon.ico deleted file mode 100644 index defe0a0..0000000 Binary files a/docs/images/favicon.ico and /dev/null differ diff --git a/docs/images/ref.pxm b/docs/images/ref.pxm deleted file mode 100644 index e623fec..0000000 Binary files a/docs/images/ref.pxm and /dev/null differ diff --git a/docs/index.jade b/docs/index.jade deleted file mode 100644 index cb892d9..0000000 --- a/docs/index.jade +++ /dev/null @@ -1,264 +0,0 @@ -doctype html -html(lang="en") - head - meta(charset="utf-8") - title "ref" documentation v#{package.version} - meta(name="description", content=package.description) - meta(name="keywords", content=['node.js', package.name].concat(package.keywords).join(', ')) - meta(name="author", content="Nathan Rajlich") - meta(name="viewport", content="width=device-width, initial-scale=1, maximum-scale=1") - - link(rel="stylesheet", href="stylesheets/hightlight.css") - link(rel="stylesheet", href="stylesheets/base.css") - link(rel="stylesheet", href="stylesheets/skeleton.css") - link(rel="stylesheet", href="stylesheets/layout.css") - - link(rel="shortcut icon", href="images/favicon.ico") - link(rel="apple-touch-icon", href="images/apple-touch-icon.png") - link(rel="apple-touch-icon", sizes="72x72", href="images/apple-touch-icon-72x72.png") - link(rel="apple-touch-icon", sizes="114x114", href="images/apple-touch-icon-114x114.png") - - body - .container - .columns.three.logo - a(href="") - h1 #{package.name} - span.pointer * - span.version v#{package.version} - .columns.thirteen.subtitle - h3= package.description - .columns.sixteen.intro - h4 What is ref? - p - code ref - | is a native addon for - a(href="http://nodejs.org") Node.js - | that aids in doing C programming in JavaScript, by extending - | the built-in - a(href="http://nodejs.org/api/buffer.html") - code Buffer - | class - | with some fancy additions like: - ul - li Getting the memory address of a Buffer - li Checking the endianness of the processor - li Checking if a Buffer represents the NULL pointer - li Reading and writing "pointers" with Buffers - li Reading and writing C Strings (NULL-terminated) - li Reading and writing JavaScript Object references - li Reading and writing - strong int64_t - | and - strong uint64_t - | values - li A "type" convention to define the contents of a Buffer - p - | There is indeed a lot of - em meat - | to - code ref - | , but it all fits together in one way or another in the end. - br - | For simplicity, - code ref - | 's API can be broken down into 3 sections: - a.nav.columns.five(href='#exports') - h4 ref exports - p - | All the static versions of - code ref - | 's functions and default "types" available on the exports returned from - code require('ref') - | . - a.nav.columns.five(href='#types') - h4 "type" system - p - | The - em "type" - | system allows you to define a "type" on any Buffer instance, and then - | use generic - code ref() - | and - code deref() - | functions to reference and dereference values. - a.nav.columns.five(href='#extensions') - h4 Buffer extensions - p - code Buffer.prototype - | gets extended with some convenience functions. These all just mirror - | their static counterpart, using the Buffer's - code this - | variable as the - code buffer - | variable. - - - hr - .columns.eight.section.exports - a(name="exports") - a(href="#exports") - h2 ref exports - .columns.sixteen.intro - p - | This section documents all the functions exported from - code require('ref') - | . - each doc in exports - if (!doc.ignore) - .columns.sixteen.section - a(name='exports-' + doc.name) - a(href='#exports-' + doc.name) - isFunc = doc.type == 'method' || doc.isPrivate - h3 - | ref.#{doc.name} - if (isFunc) - | ( - each param, i in doc.paramTypes - span.param #{param.types.join('|')} #{param.name} - if (i + 1 < doc.paramTypes.length) - | , - | ) - if (doc.returnType) - | - span.rtn → #{doc.returnType.types.join('|')} - if (!isFunc) - | - span.rtn ⇒ #{doc.type} - if (doc.paramTypes.length > 0 || doc.returnType) - ul - each param in doc.paramTypes - li #{param.name} - !{param.description} - if (doc.returnType) - li - strong Return: - | !{doc.returnType.description} - != (doc && doc.description.full || '').replace(/\
/g, ' ') - - - hr - .columns.eight.section.types - a(name="types") - a(href="#types") - h2 - em "type" - | system - .columns.sixteen.intro.types - p - | A "type" in - code ref - | is simply an plain 'ol JavaScript Object, with a set - | of expected properties attached that implement the logic for getting - | & setting values on a given - code Buffer - | instance. - p - | To attach a "type" to a Buffer instance, you simply attach the "type" - | object to the Buffer's type property. - code ref - | comes with a set of commonly used types which are described in this - | section. - h4 Creating your own "type" - p - | It's trivial to create your own "type" that reads and writes your - | own custom datatype/class to and from Buffer instances using - code ref - | 's unified API. - br - | To create your own "type", simply create a JavaScript Object with - | the following properties defined: - table - tr - th Name - th Data Type - th Description - tr - td: code size - td: code Number - td The size in bytes required to hold this datatype. - tr - td: code indirection - td: code Number - td - | The current level of indirection of the buffer. When defining - | your own "types", just set this value to 1. - tr - td: code get - td: code Function - td - | The function to invoke when - a(href="#exports-get") - code ref.get() - | is invoked on a buffer of this type. - tr - td: code set - td: code Function - td - | The function to invoke when - a(href="#exports-set") - code ref.set() - | is invoked on a buffer of this type. - tr - td: code name - td: code String - td - em (Optional) - | The name to use during debugging for this datatype. - tr - td: code alignment - td: code Number - td - em (Optional) - | The alignment of this datatype when placed inside a struct. - | Defaults to the type's - code size - | . - h4 The built-in "types" - p - | Here is the list of - code ref - | 's built-in "type" Objects. All these built-in "types" can be found - | on the - code ref.types - | export Object. All the built-in types use "native endianness" when - | multi-byte datatypes are involved. - each doc in types - if (!doc.ignore) - .columns.sixteen.section - a(name='types-' + doc.name) - a(href='#types-' + doc.name) - h3 types.#{doc.name} - != doc.description.full.replace(/\
/g, ' ') - - - hr - .columns.eight.section.exports - a(name="extensions") - a(href="#extensions") - h2 Buffer extensions - .columns.sixteen.intro - p - code Buffer.prototype - | gets extended with some convenience functions that you can use in - | your modules and/or applications. - each doc in extensions - if (!doc.ignore) - .columns.sixteen.section - a(name='extensions-' + doc.name) - a(href='#extensions-' + doc.name) - h3 Buffer##{doc.name}() - if (doc.name === 'inspect') - != doc.description.full.replace(/\
/g, ' ') - else - p - | Shorthand for - a(href='#exports-' + doc.name) - code ref.#{doc.name}(this, …) - | . - != (doc.ref && doc.ref.description.full || '').replace(/\
/g, ' ') - - - .ribbon - a(href="https://github.com/TooTallNate/ref", rel="me") Fork me on GitHub - - script(src="scripts/jquery-1.7.2.min.js") - script(src="scripts/main.js") diff --git a/docs/scripts/jquery-1.7.2.min.js b/docs/scripts/jquery-1.7.2.min.js deleted file mode 100644 index 16ad06c..0000000 --- a/docs/scripts/jquery-1.7.2.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! jQuery v1.7.2 jquery.com | jquery.org/license */ -(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cu(a){if(!cj[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ck||(ck=c.createElement("iframe"),ck.frameBorder=ck.width=ck.height=0),b.appendChild(ck);if(!cl||!ck.createElement)cl=(ck.contentWindow||ck.contentDocument).document,cl.write((f.support.boxModel?"":"")+""),cl.close();d=cl.createElement(a),cl.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ck)}cj[a]=e}return cj[a]}function ct(a,b){var c={};f.each(cp.concat.apply([],cp.slice(0,b)),function(){c[this]=a});return c}function cs(){cq=b}function cr(){setTimeout(cs,0);return cq=f.now()}function ci(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ch(){try{return new a.XMLHttpRequest}catch(b){}}function cb(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){if(c!=="border")for(;e=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?+d:j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.2",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a!=null&&a==a.window},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){if(typeof c!="string"||!c)return null;var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c
a",d=p.getElementsByTagName("*"),e=p.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=p.getElementsByTagName("input")[0],b={leadingWhitespace:p.firstChild.nodeType===3,tbody:!p.getElementsByTagName("tbody").length,htmlSerialize:!!p.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:p.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,pixelMargin:!0},f.boxModel=b.boxModel=c.compatMode==="CSS1Compat",i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete p.test}catch(r){b.deleteExpando=!1}!p.addEventListener&&p.attachEvent&&p.fireEvent&&(p.attachEvent("onclick",function(){b.noCloneEvent=!1}),p.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),i.setAttribute("name","t"),p.appendChild(i),j=c.createDocumentFragment(),j.appendChild(p.lastChild),b.checkClone=j.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,j.removeChild(i),j.appendChild(p);if(p.attachEvent)for(n in{submit:1,change:1,focusin:1})m="on"+n,o=m in p,o||(p.setAttribute(m,"return;"),o=typeof p[m]=="function"),b[n+"Bubbles"]=o;j.removeChild(p),j=g=h=p=i=null,f(function(){var d,e,g,h,i,j,l,m,n,q,r,s,t,u=c.getElementsByTagName("body")[0];!u||(m=1,t="padding:0;margin:0;border:",r="position:absolute;top:0;left:0;width:1px;height:1px;",s=t+"0;visibility:hidden;",n="style='"+r+t+"5px solid #000;",q="

"+""+"
",d=c.createElement("div"),d.style.cssText=s+"width:0;height:0;position:static;top:0;margin-top:"+m+"px",u.insertBefore(d,u.firstChild),p=c.createElement("div"),d.appendChild(p),p.innerHTML="
t
",k=p.getElementsByTagName("td"),o=k[0].offsetHeight===0,k[0].style.display="",k[1].style.display="none",b.reliableHiddenOffsets=o&&k[0].offsetHeight===0,a.getComputedStyle&&(p.innerHTML="",l=c.createElement("div"),l.style.width="0",l.style.marginRight="0",p.style.width="2px",p.appendChild(l),b.reliableMarginRight=(parseInt((a.getComputedStyle(l,null)||{marginRight:0}).marginRight,10)||0)===0),typeof p.style.zoom!="undefined"&&(p.innerHTML="",p.style.width=p.style.padding="1px",p.style.border=0,p.style.overflow="hidden",p.style.display="inline",p.style.zoom=1,b.inlineBlockNeedsLayout=p.offsetWidth===3,p.style.display="block",p.style.overflow="visible",p.innerHTML="
",b.shrinkWrapBlocks=p.offsetWidth!==3),p.style.cssText=r+s,p.innerHTML=q,e=p.firstChild,g=e.firstChild,i=e.nextSibling.firstChild.firstChild,j={doesNotAddBorder:g.offsetTop!==5,doesAddBorderForTableAndCells:i.offsetTop===5},g.style.position="fixed",g.style.top="20px",j.fixedPosition=g.offsetTop===20||g.offsetTop===15,g.style.position=g.style.top="",e.style.overflow="hidden",e.style.position="relative",j.subtractsBorderForOverflowNotVisible=g.offsetTop===-5,j.doesNotIncludeMarginInBodyOffset=u.offsetTop!==m,a.getComputedStyle&&(p.style.marginTop="1%",b.pixelMargin=(a.getComputedStyle(p,null)||{marginTop:0}).marginTop!=="1%"),typeof d.style.zoom!="undefined"&&(d.style.zoom=1),u.removeChild(d),l=p=d=null,f.extend(b,j))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e1,null,!1)},removeData:function(a){return this.each(function(){f.removeData(this,a)})}}),f.extend({_mark:function(a,b){a&&(b=(b||"fx")+"mark",f._data(a,b,(f._data(a,b)||0)+1))},_unmark:function(a,b,c){a!==!0&&(c=b,b=a,a=!1);if(b){c=c||"fx";var d=c+"mark",e=a?0:(f._data(b,d)||1)-1;e?f._data(b,d,e):(f.removeData(b,d,!0),n(b,c,"mark"))}},queue:function(a,b,c){var d;if(a){b=(b||"fx")+"queue",d=f._data(a,b),c&&(!d||f.isArray(c)?d=f._data(a,b,f.makeArray(c)):d.push(c));return d||[]}},dequeue:function(a,b){b=b||"fx";var c=f.queue(a,b),d=c.shift(),e={};d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),f._data(a,b+".run",e),d.call(a,function(){f.dequeue(a,b)},e)),c.length||(f.removeData(a,b+"queue "+b+".run",!0),n(a,b,"queue"))}}),f.fn.extend({queue:function(a,c){var d=2;typeof a!="string"&&(c=a,a="fx",d--);if(arguments.length1)},removeAttr:function(a){return this.each(function(){f.removeAttr(this,a)})},prop:function(a,b){return f.access(this,f.prop,a,b,arguments.length>1)},removeProp:function(a){a=f.propFix[a]||a;return this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,g,h,i;if(f.isFunction(a))return this.each(function(b){f(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(p);for(c=0,d=this.length;c-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.type]||f.valHooks[this.nodeName.toLowerCase()];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.type]||f.valHooks[g.nodeName.toLowerCase()];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h,i=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;i=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/(?:^|\s)hover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function( -a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")};f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler,g=p.selector),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;le&&j.push({elem:this,matches:d.slice(e)});for(k=0;k0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));o.match.globalPOS=p;var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/]","i"),bd=/checked\s*(?:[^=]|=\s*.checked.)/i,be=/\/(java|ecma)script/i,bf=/^\s*",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div
","
"]),f.fn.extend({text:function(a){return f.access(this,function(a){return a===b?f.text(this):this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f -.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){return f.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return c.nodeType===1?c.innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(;d1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||f.isXMLDoc(a)||!bc.test("<"+a.nodeName+">")?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g,h,i,j=[];b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);for(var k=0,l;(l=a[k])!=null;k++){typeof l=="number"&&(l+="");if(!l)continue;if(typeof l=="string")if(!_.test(l))l=b.createTextNode(l);else{l=l.replace(Y,"<$1>");var m=(Z.exec(l)||["",""])[1].toLowerCase(),n=bg[m]||bg._default,o=n[0],p=b.createElement("div"),q=bh.childNodes,r;b===c?bh.appendChild(p):U(b).appendChild(p),p.innerHTML=n[1]+l+n[2];while(o--)p=p.lastChild;if(!f.support.tbody){var s=$.test(l),t=m==="table"&&!s?p.firstChild&&p.firstChild.childNodes:n[1]===""&&!s?p.childNodes:[];for(i=t.length-1;i>=0;--i)f.nodeName(t[i],"tbody")&&!t[i].childNodes.length&&t[i].parentNode.removeChild(t[i])}!f.support.leadingWhitespace&&X.test(l)&&p.insertBefore(b.createTextNode(X.exec(l)[0]),p.firstChild),l=p.childNodes,p&&(p.parentNode.removeChild(p),q.length>0&&(r=q[q.length-1],r&&r.parentNode&&r.parentNode.removeChild(r)))}var u;if(!f.support.appendChecked)if(l[0]&&typeof (u=l.length)=="number")for(i=0;i1)},f.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=by(a,"opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":f.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var g,h,i=f.camelCase(c),j=a.style,k=f.cssHooks[i];c=f.cssProps[i]||i;if(d===b){if(k&&"get"in k&&(g=k.get(a,!1,e))!==b)return g;return j[c]}h=typeof d,h==="string"&&(g=bu.exec(d))&&(d=+(g[1]+1)*+g[2]+parseFloat(f.css(a,c)),h="number");if(d==null||h==="number"&&isNaN(d))return;h==="number"&&!f.cssNumber[i]&&(d+="px");if(!k||!("set"in k)||(d=k.set(a,d))!==b)try{j[c]=d}catch(l){}}},css:function(a,c,d){var e,g;c=f.camelCase(c),g=f.cssHooks[c],c=f.cssProps[c]||c,c==="cssFloat"&&(c="float");if(g&&"get"in g&&(e=g.get(a,!0,d))!==b)return e;if(by)return by(a,c)},swap:function(a,b,c){var d={},e,f;for(f in b)d[f]=a.style[f],a.style[f]=b[f];e=c.call(a);for(f in b)a.style[f]=d[f];return e}}),f.curCSS=f.css,c.defaultView&&c.defaultView.getComputedStyle&&(bz=function(a,b){var c,d,e,g,h=a.style;b=b.replace(br,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b))),!f.support.pixelMargin&&e&&bv.test(b)&&bt.test(c)&&(g=h.width,h.width=c,c=e.width,h.width=g);return c}),c.documentElement.currentStyle&&(bA=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f==null&&g&&(e=g[b])&&(f=e),bt.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),by=bz||bA,f.each(["height","width"],function(a,b){f.cssHooks[b]={get:function(a,c,d){if(c)return a.offsetWidth!==0?bB(a,b,d):f.swap(a,bw,function(){return bB(a,b,d)})},set:function(a,b){return bs.test(b)?b+"px":b}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bq.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bp,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bp.test(g)?g.replace(bp,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){return f.swap(a,{display:"inline-block"},function(){return b?by(a,"margin-right"):a.style.marginRight})}})}),f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)}),f.each({margin:"",padding:"",border:"Width"},function(a,b){f.cssHooks[a+b]={expand:function(c){var d,e=typeof c=="string"?c.split(" "):[c],f={};for(d=0;d<4;d++)f[a+bx[d]+b]=e[d]||e[d-2]||e[0];return f}}});var bC=/%20/g,bD=/\[\]$/,bE=/\r?\n/g,bF=/#.*$/,bG=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bH=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bI=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bJ=/^(?:GET|HEAD)$/,bK=/^\/\//,bL=/\?/,bM=/)<[^<]*)*<\/script>/gi,bN=/^(?:select|textarea)/i,bO=/\s+/,bP=/([?&])_=[^&]*/,bQ=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bR=f.fn.load,bS={},bT={},bU,bV,bW=["*/"]+["*"];try{bU=e.href}catch(bX){bU=c.createElement("a"),bU.href="",bU=bU.href}bV=bQ.exec(bU.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bR)return bR.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bM,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bN.test(this.nodeName)||bH.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bE,"\r\n")}}):{name:b.name,value:c.replace(bE,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b$(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b$(a,b);return a},ajaxSettings:{url:bU,isLocal:bI.test(bV[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bW},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bY(bS),ajaxTransport:bY(bT),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?ca(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cb(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bG.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bF,"").replace(bK,bV[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bO),d.crossDomain==null&&(r=bQ.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bV[1]&&r[2]==bV[2]&&(r[3]||(r[1]==="http:"?80:443))==(bV[3]||(bV[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bZ(bS,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bJ.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bL.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bP,"$1_="+x);d.url=y+(y===d.url?(bL.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bW+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bZ(bT,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)b_(g,a[g],c,e);return d.join("&").replace(bC,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cc=f.now(),cd=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cc++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=typeof b.data=="string"&&/^application\/x\-www\-form\-urlencoded/.test(b.contentType);if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(cd.test(b.url)||e&&cd.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(cd,l),b.url===j&&(e&&(k=k.replace(cd,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var ce=a.ActiveXObject?function(){for(var a in cg)cg[a](0,1)}:!1,cf=0,cg;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ch()||ci()}:ch,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,ce&&delete cg[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n);try{m.text=h.responseText}catch(a){}try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cf,ce&&(cg||(cg={},f(a).unload(ce)),cg[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cj={},ck,cl,cm=/^(?:toggle|show|hide)$/,cn=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,co,cp=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cq;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(ct("show",3),a,b,c);for(var g=0,h=this.length;g=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,c){var d=/Y/.test(c);f.fn[a]=function(e){return f.access(this,function(a,e,g){var h=cy(a);if(g===b)return h?c in h?h[c]:f.support.boxModel&&h.document.documentElement[e]||h.document.body[e]:a[e];h?h.scrollTo(d?f(h).scrollLeft():g,d?g:f(h).scrollTop()):a[e]=g},a,e,arguments.length,null)}}),f.each({Height:"height",Width:"width"},function(a,c){var d="client"+a,e="scroll"+a,g="offset"+a;f.fn["inner"+a]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,c,"padding")):this[c]():null},f.fn["outer"+a]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,c,a?"margin":"border")):this[c]():null},f.fn[c]=function(a){return f.access(this,function(a,c,h){var i,j,k,l;if(f.isWindow(a)){i=a.document,j=i.documentElement[d];return f.support.boxModel&&j||i.body&&i.body[d]||j}if(a.nodeType===9){i=a.documentElement;if(i[d]>=i[e])return i[d];return Math.max(a.body[e],i[e],a.body[g],i[g])}if(h===b){k=f.css(a,c),l=parseFloat(k);return f.isNumeric(l)?l:k}f(a).css(c,h)},c,a,arguments.length,null)}}),a.jQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window); \ No newline at end of file diff --git a/docs/scripts/main.js b/docs/scripts/main.js deleted file mode 100644 index 652c3df..0000000 --- a/docs/scripts/main.js +++ /dev/null @@ -1,25 +0,0 @@ - -/** - * Animated scroll to named anchors. - */ - -$(document.body).on('click', 'a', function () { - var href = $(this).attr('href') - if (href[0] === '#') { - scrollTo(href) - window.history && history.pushState({}, name, href) - return false - } -}) - -function scrollTo (hash) { - var name = hash.substring(1) - var target = $('a[name="' + name + '"]') - if (target.length) { - $('html, body').animate({ scrollTop: target.offset().top } - , { duration: 500, easing: 'swing'}) - } else { - console.log('documentation not written: %s', name) - } - return target -} diff --git a/docs/stylesheets/base.css b/docs/stylesheets/base.css deleted file mode 100644 index 8e1a6d7..0000000 --- a/docs/stylesheets/base.css +++ /dev/null @@ -1,267 +0,0 @@ -/* -* Skeleton V1.2 -* Copyright 2011, Dave Gamache -* www.getskeleton.com -* Free to use under the MIT license. -* http://www.opensource.org/licenses/mit-license.php -* 6/20/2012 -*/ - - -/* Table of Content -================================================== - #Reset & Basics - #Basic Styles - #Site Styles - #Typography - #Links - #Lists - #Images - #Buttons - #Forms - #Misc */ - - -/* #Reset & Basics (Inspired by E. Meyers) -================================================== */ - html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { - margin: 0; - padding: 0; - border: 0; - font-size: 100%; - font: inherit; - vertical-align: baseline; } - article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { - display: block; } - body { - line-height: 1; } - ol, ul { - list-style: none; } - blockquote, q { - quotes: none; } - blockquote:before, blockquote:after, - q:before, q:after { - content: ''; - content: none; } - table { - border-collapse: collapse; - border-spacing: 0; } - - -/* #Basic Styles -================================================== */ - body { - background: #fff; - font: 14px/21px "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif; - color: #444; - -webkit-font-smoothing: antialiased; /* Fix for webkit rendering */ - -webkit-text-size-adjust: 100%; - } - - -/* #Typography -================================================== */ - h1, h2, h3, h4, h5, h6 { - color: #181818; - font-family: "Georgia", "Times New Roman", serif; - font-weight: normal; } - h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { font-weight: inherit; } - h1 { font-size: 46px; line-height: 50px; margin-bottom: 14px;} - h2 { font-size: 35px; line-height: 40px; margin-bottom: 10px; } - h3 { font-size: 28px; line-height: 34px; margin-bottom: 8px; } - h4 { font-size: 21px; line-height: 30px; margin-bottom: 4px; } - h5 { font-size: 17px; line-height: 24px; } - h6 { font-size: 14px; line-height: 21px; } - .subheader { color: #777; } - - p { margin: 0 0 20px 0; } - p img { margin: 0; } - p.lead { font-size: 21px; line-height: 27px; color: #777; } - - em { font-style: italic; } - strong { font-weight: bold; color: #333; } - small { font-size: 80%; } - -/* Blockquotes */ - blockquote, blockquote p { font-size: 17px; line-height: 24px; color: #777; font-style: italic; } - blockquote { margin: 0 0 20px; padding: 9px 20px 0 19px; border-left: 1px solid #ddd; } - blockquote cite { display: block; font-size: 12px; color: #555; } - blockquote cite:before { content: "\2014 \0020"; } - blockquote cite a, blockquote cite a:visited, blockquote cite a:visited { color: #555; } - - hr { border: solid #ddd; border-width: 1px 0 0; clear: both; margin: 10px 0 30px; height: 0; } - - -/* #Links -================================================== */ - a, a:visited { color: #333; text-decoration: underline; outline: 0; } - a:hover, a:focus { color: #000; } - p a, p a:visited { line-height: inherit; } - - -/* #Lists -================================================== */ - ul, ol { margin-bottom: 20px; } - ul { list-style: none outside; } - ol { list-style: decimal; } - ol, ul.square, ul.circle, ul.disc { margin-left: 30px; } - ul.square { list-style: square outside; } - ul.circle { list-style: circle outside; } - ul.disc { list-style: disc outside; } - ul ul, ul ol, - ol ol, ol ul { margin: 4px 0 5px 30px; font-size: 90%; } - ul ul li, ul ol li, - ol ol li, ol ul li { margin-bottom: 6px; } - li { line-height: 18px; margin-bottom: 12px; } - ul.large li { line-height: 21px; } - li p { line-height: 21px; } - -/* #Images -================================================== */ - - img.scale-with-grid { - max-width: 100%; - height: auto; } - - -/* #Buttons -================================================== */ - - .button, - button, - input[type="submit"], - input[type="reset"], - input[type="button"] { - background: #eee; /* Old browsers */ - background: #eee -moz-linear-gradient(top, rgba(255,255,255,.2) 0%, rgba(0,0,0,.2) 100%); /* FF3.6+ */ - background: #eee -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,.2)), color-stop(100%,rgba(0,0,0,.2))); /* Chrome,Safari4+ */ - background: #eee -webkit-linear-gradient(top, rgba(255,255,255,.2) 0%,rgba(0,0,0,.2) 100%); /* Chrome10+,Safari5.1+ */ - background: #eee -o-linear-gradient(top, rgba(255,255,255,.2) 0%,rgba(0,0,0,.2) 100%); /* Opera11.10+ */ - background: #eee -ms-linear-gradient(top, rgba(255,255,255,.2) 0%,rgba(0,0,0,.2) 100%); /* IE10+ */ - background: #eee linear-gradient(top, rgba(255,255,255,.2) 0%,rgba(0,0,0,.2) 100%); /* W3C */ - border: 1px solid #aaa; - border-top: 1px solid #ccc; - border-left: 1px solid #ccc; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; - color: #444; - display: inline-block; - font-size: 11px; - font-weight: bold; - text-decoration: none; - text-shadow: 0 1px rgba(255, 255, 255, .75); - cursor: pointer; - margin-bottom: 20px; - line-height: normal; - padding: 8px 10px; - font-family: "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif; } - - .button:hover, - button:hover, - input[type="submit"]:hover, - input[type="reset"]:hover, - input[type="button"]:hover { - color: #222; - background: #ddd; /* Old browsers */ - background: #ddd -moz-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%); /* FF3.6+ */ - background: #ddd -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,.3)), color-stop(100%,rgba(0,0,0,.3))); /* Chrome,Safari4+ */ - background: #ddd -webkit-linear-gradient(top, rgba(255,255,255,.3) 0%,rgba(0,0,0,.3) 100%); /* Chrome10+,Safari5.1+ */ - background: #ddd -o-linear-gradient(top, rgba(255,255,255,.3) 0%,rgba(0,0,0,.3) 100%); /* Opera11.10+ */ - background: #ddd -ms-linear-gradient(top, rgba(255,255,255,.3) 0%,rgba(0,0,0,.3) 100%); /* IE10+ */ - background: #ddd linear-gradient(top, rgba(255,255,255,.3) 0%,rgba(0,0,0,.3) 100%); /* W3C */ - border: 1px solid #888; - border-top: 1px solid #aaa; - border-left: 1px solid #aaa; } - - .button:active, - button:active, - input[type="submit"]:active, - input[type="reset"]:active, - input[type="button"]:active { - border: 1px solid #666; - background: #ccc; /* Old browsers */ - background: #ccc -moz-linear-gradient(top, rgba(255,255,255,.35) 0%, rgba(10,10,10,.4) 100%); /* FF3.6+ */ - background: #ccc -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,.35)), color-stop(100%,rgba(10,10,10,.4))); /* Chrome,Safari4+ */ - background: #ccc -webkit-linear-gradient(top, rgba(255,255,255,.35) 0%,rgba(10,10,10,.4) 100%); /* Chrome10+,Safari5.1+ */ - background: #ccc -o-linear-gradient(top, rgba(255,255,255,.35) 0%,rgba(10,10,10,.4) 100%); /* Opera11.10+ */ - background: #ccc -ms-linear-gradient(top, rgba(255,255,255,.35) 0%,rgba(10,10,10,.4) 100%); /* IE10+ */ - background: #ccc linear-gradient(top, rgba(255,255,255,.35) 0%,rgba(10,10,10,.4) 100%); /* W3C */ } - - .button.full-width, - button.full-width, - input[type="submit"].full-width, - input[type="reset"].full-width, - input[type="button"].full-width { - width: 100%; - padding-left: 0 !important; - padding-right: 0 !important; - text-align: center; } - - /* Fix for odd Mozilla border & padding issues */ - button::-moz-focus-inner, - input::-moz-focus-inner { - border: 0; - padding: 0; - } - - -/* #Forms -================================================== */ - - form { - margin-bottom: 20px; } - fieldset { - margin-bottom: 20px; } - input[type="text"], - input[type="password"], - input[type="email"], - textarea, - select { - border: 1px solid #ccc; - padding: 6px 4px; - outline: none; - -moz-border-radius: 2px; - -webkit-border-radius: 2px; - border-radius: 2px; - font: 13px "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif; - color: #777; - margin: 0; - width: 210px; - max-width: 100%; - display: block; - margin-bottom: 20px; - background: #fff; } - select { - padding: 0; } - input[type="text"]:focus, - input[type="password"]:focus, - input[type="email"]:focus, - textarea:focus { - border: 1px solid #aaa; - color: #444; - -moz-box-shadow: 0 0 3px rgba(0,0,0,.2); - -webkit-box-shadow: 0 0 3px rgba(0,0,0,.2); - box-shadow: 0 0 3px rgba(0,0,0,.2); } - textarea { - min-height: 60px; } - label, - legend { - display: block; - font-weight: bold; - font-size: 13px; } - select { - width: 220px; } - input[type="checkbox"] { - display: inline; } - label span, - legend span { - font-weight: normal; - font-size: 13px; - color: #444; } - -/* #Misc -================================================== */ - .remove-bottom { margin-bottom: 0 !important; } - .half-bottom { margin-bottom: 10px !important; } - .add-bottom { margin-bottom: 20px !important; } diff --git a/docs/stylesheets/hightlight.css b/docs/stylesheets/hightlight.css deleted file mode 120000 index cb2e355..0000000 --- a/docs/stylesheets/hightlight.css +++ /dev/null @@ -1 +0,0 @@ -../../node_modules/highlight.js/src/styles/solarized_light.css \ No newline at end of file diff --git a/docs/stylesheets/layout.css b/docs/stylesheets/layout.css deleted file mode 100644 index e59e695..0000000 --- a/docs/stylesheets/layout.css +++ /dev/null @@ -1,212 +0,0 @@ -/* -* Skeleton V1.2 -* Copyright 2011, Dave Gamache -* www.getskeleton.com -* Free to use under the MIT license. -* http://www.opensource.org/licenses/mit-license.php -* 6/20/2012 -*/ - -/* Table of Content -================================================== - #Site Styles - #Page Styles - #Media Queries - #Font-Face */ - -/* #Site Styles -================================================== */ - -/* #Page Styles -================================================== */ - -/* #Media Queries -================================================== */ - - /* Smaller than standard 960 (devices and browsers) */ - @media only screen and (max-width: 959px) {} - - /* Tablet Portrait size to standard 960 (devices and browsers) */ - @media only screen and (min-width: 768px) and (max-width: 959px) {} - - /* All Mobile Sizes (devices and browser) */ - @media only screen and (max-width: 767px) {} - - /* Mobile Landscape Size to Tablet Portrait (devices and browsers) */ - @media only screen and (min-width: 480px) and (max-width: 767px) {} - - /* Mobile Portrait Size to Mobile Landscape Size (devices and browsers) */ - @media only screen and (max-width: 479px) {} - - -/* #Font-Face -================================================== */ -/* This is the proper syntax for an @font-face file - Just create a "fonts" folder at the root, - copy your FontName into code below and remove - comment brackets */ - -/* @font-face { - font-family: 'FontName'; - src: url('../fonts/FontName.eot'); - src: url('../fonts/FontName.eot?iefix') format('eot'), - url('../fonts/FontName.woff') format('woff'), - url('../fonts/FontName.ttf') format('truetype'), - url('../fonts/FontName.svg#webfontZam02nTh') format('svg'); - font-weight: normal; - font-style: normal; } -*/ - - -/* `ref` stuff */ -code, pre { - background-color: #fcf8f2; - border: solid 1px rgba(68, 68, 68, 0.3); - border-radius: 2px; - padding: 1px 2px; - -webkit-transition-property: background-color; - -webkit-transition-duration: 0.5s; - -webkit-transition-delay: 0s; -} - -pre { - padding: 10px; -} - -pre code { - background-color: transparent; - border: none; - padding: 0px; -} - -th { - font-weight: bold; -} - -a { - text-decoration: none; -} - -p { - margin: 10px 0; -} - -p a { - text-decoration: underline; -} - -ul { - list-style: disc; - margin-left: 40px; -} - -h3 { - color: #777; -} - -.container { - margin: 100px auto; -} - -.logo h1 .pointer { - color: #dbe8d9; - -webkit-transition-property: color; - -webkit-transition-duration: 0.5s; - -webkit-transition-delay: 0s; -} - -.logo h1:hover .pointer { - color: #444; -} - -.logo h1 .version { - color: #aaa; - font-size: 0.3em; - position: absolute; - top: 12px; - left: 70px; -} - -.types table, .types tr { - border: solid 1px #444; -} - -.types td, .types th { - border: solid 1px #444; - padding: 4px; -} - -.param, .rtn { - display: inline-block; - font-size: 0.8em; - font-style: italic; - color: #444; -} - -a.nav { - border: solid 1px transparent; - border-radius: 2px; - padding: 3px; - margin-bottom: 20px; - text-decoration: none; - background-color: transparent; - -webkit-transition-property: background-color, border-color; - -webkit-transition-duration: 0.5s; - -webkit-transition-delay: 0s; -} - -a.nav:hover { - background-color: #fcf8f2; - border-color: rgba(68, 68, 68, 0.3); -} - -a.nav:hover code { - background-color: #dbe8d9; -} - -.subtitle h3 { - margin-top: 18px; -} - -.section { - margin-top: 40px; -} - - -/* GitHub Ribbon - * http://unindented.org/articles/2009/10/github-ribbon-using-css-transforms */ -.ribbon { - background-color: #fcf8f2; - overflow: hidden; - /* top right corner */ - position: fixed; - right: -3em; - top: 2.5em; - /* 45 deg ccw rotation */ - -moz-transform: rotate(45deg); - -webkit-transform: rotate(45deg); - /* shadow */ - -moz-box-shadow: 0 0 0.5em #888; - -webkit-box-shadow: 0 0 0.5em #888; - /* hover transition */ - -webkit-transition-property: background-color; - -webkit-transition-duration: 0.3s; - -webkit-transition-delay: 0s; -} - -.ribbon a { - border: solid 1px rgba(68, 68, 68, 0.4); - color: #444; - display: block; - font: bold 81.25% 'Helvetiva Neue', Helvetica, Arial, sans-serif; - margin: 0.05em 0 0.075em 0; - padding: 0.5em 3.5em; - text-align: center; - text-decoration: none; - /* shadow */ - text-shadow: 0 0 0.5em #888; -} - -.ribbon:hover { - background-color: #dbe8d9; -} diff --git a/docs/stylesheets/skeleton.css b/docs/stylesheets/skeleton.css deleted file mode 100644 index 5db3d38..0000000 --- a/docs/stylesheets/skeleton.css +++ /dev/null @@ -1,242 +0,0 @@ -/* -* Skeleton V1.2 -* Copyright 2011, Dave Gamache -* www.getskeleton.com -* Free to use under the MIT license. -* http://www.opensource.org/licenses/mit-license.php -* 6/20/2012 -*/ - - -/* Table of Contents -================================================== - #Base 960 Grid - #Tablet (Portrait) - #Mobile (Portrait) - #Mobile (Landscape) - #Clearing */ - - - -/* #Base 960 Grid -================================================== */ - - .container { position: relative; width: 960px; margin: 0 auto; padding: 0; } - .container .column, - .container .columns { float: left; display: inline; margin-left: 10px; margin-right: 10px; } - .row { margin-bottom: 20px; } - - /* Nested Column Classes */ - .column.alpha, .columns.alpha { margin-left: 0; } - .column.omega, .columns.omega { margin-right: 0; } - - /* Base Grid */ - .container .one.column, - .container .one.columns { width: 40px; } - .container .two.columns { width: 100px; } - .container .three.columns { width: 160px; } - .container .four.columns { width: 220px; } - .container .five.columns { width: 280px; } - .container .six.columns { width: 340px; } - .container .seven.columns { width: 400px; } - .container .eight.columns { width: 460px; } - .container .nine.columns { width: 520px; } - .container .ten.columns { width: 580px; } - .container .eleven.columns { width: 640px; } - .container .twelve.columns { width: 700px; } - .container .thirteen.columns { width: 760px; } - .container .fourteen.columns { width: 820px; } - .container .fifteen.columns { width: 880px; } - .container .sixteen.columns { width: 940px; } - - .container .one-third.column { width: 300px; } - .container .two-thirds.column { width: 620px; } - - /* Offsets */ - .container .offset-by-one { padding-left: 60px; } - .container .offset-by-two { padding-left: 120px; } - .container .offset-by-three { padding-left: 180px; } - .container .offset-by-four { padding-left: 240px; } - .container .offset-by-five { padding-left: 300px; } - .container .offset-by-six { padding-left: 360px; } - .container .offset-by-seven { padding-left: 420px; } - .container .offset-by-eight { padding-left: 480px; } - .container .offset-by-nine { padding-left: 540px; } - .container .offset-by-ten { padding-left: 600px; } - .container .offset-by-eleven { padding-left: 660px; } - .container .offset-by-twelve { padding-left: 720px; } - .container .offset-by-thirteen { padding-left: 780px; } - .container .offset-by-fourteen { padding-left: 840px; } - .container .offset-by-fifteen { padding-left: 900px; } - - - -/* #Tablet (Portrait) -================================================== */ - - /* Note: Design for a width of 768px */ - - @media only screen and (min-width: 768px) and (max-width: 959px) { - .container { width: 768px; } - .container .column, - .container .columns { margin-left: 10px; margin-right: 10px; } - .column.alpha, .columns.alpha { margin-left: 0; margin-right: 10px; } - .column.omega, .columns.omega { margin-right: 0; margin-left: 10px; } - .alpha.omega { margin-left: 0; margin-right: 0; } - - .container .one.column, - .container .one.columns { width: 28px; } - .container .two.columns { width: 76px; } - .container .three.columns { width: 124px; } - .container .four.columns { width: 172px; } - .container .five.columns { width: 220px; } - .container .six.columns { width: 268px; } - .container .seven.columns { width: 316px; } - .container .eight.columns { width: 364px; } - .container .nine.columns { width: 412px; } - .container .ten.columns { width: 460px; } - .container .eleven.columns { width: 508px; } - .container .twelve.columns { width: 556px; } - .container .thirteen.columns { width: 604px; } - .container .fourteen.columns { width: 652px; } - .container .fifteen.columns { width: 700px; } - .container .sixteen.columns { width: 748px; } - - .container .one-third.column { width: 236px; } - .container .two-thirds.column { width: 492px; } - - /* Offsets */ - .container .offset-by-one { padding-left: 48px; } - .container .offset-by-two { padding-left: 96px; } - .container .offset-by-three { padding-left: 144px; } - .container .offset-by-four { padding-left: 192px; } - .container .offset-by-five { padding-left: 240px; } - .container .offset-by-six { padding-left: 288px; } - .container .offset-by-seven { padding-left: 336px; } - .container .offset-by-eight { padding-left: 384px; } - .container .offset-by-nine { padding-left: 432px; } - .container .offset-by-ten { padding-left: 480px; } - .container .offset-by-eleven { padding-left: 528px; } - .container .offset-by-twelve { padding-left: 576px; } - .container .offset-by-thirteen { padding-left: 624px; } - .container .offset-by-fourteen { padding-left: 672px; } - .container .offset-by-fifteen { padding-left: 720px; } - } - - -/* #Mobile (Portrait) -================================================== */ - - /* Note: Design for a width of 320px */ - - @media only screen and (max-width: 767px) { - .container { width: 300px; } - .container .columns, - .container .column { margin: 0; } - - .container .one.column, - .container .one.columns, - .container .two.columns, - .container .three.columns, - .container .four.columns, - .container .five.columns, - .container .six.columns, - .container .seven.columns, - .container .eight.columns, - .container .nine.columns, - .container .ten.columns, - .container .eleven.columns, - .container .twelve.columns, - .container .thirteen.columns, - .container .fourteen.columns, - .container .fifteen.columns, - .container .sixteen.columns, - .container .one-third.column, - .container .two-thirds.column { width: 300px; } - - /* Offsets */ - .container .offset-by-one, - .container .offset-by-two, - .container .offset-by-three, - .container .offset-by-four, - .container .offset-by-five, - .container .offset-by-six, - .container .offset-by-seven, - .container .offset-by-eight, - .container .offset-by-nine, - .container .offset-by-ten, - .container .offset-by-eleven, - .container .offset-by-twelve, - .container .offset-by-thirteen, - .container .offset-by-fourteen, - .container .offset-by-fifteen { padding-left: 0; } - - } - - -/* #Mobile (Landscape) -================================================== */ - - /* Note: Design for a width of 480px */ - - @media only screen and (min-width: 480px) and (max-width: 767px) { - .container { width: 420px; } - .container .columns, - .container .column { margin: 0; } - - .container .one.column, - .container .one.columns, - .container .two.columns, - .container .three.columns, - .container .four.columns, - .container .five.columns, - .container .six.columns, - .container .seven.columns, - .container .eight.columns, - .container .nine.columns, - .container .ten.columns, - .container .eleven.columns, - .container .twelve.columns, - .container .thirteen.columns, - .container .fourteen.columns, - .container .fifteen.columns, - .container .sixteen.columns, - .container .one-third.column, - .container .two-thirds.column { width: 420px; } - } - - -/* #Clearing -================================================== */ - - /* Self Clearing Goodness */ - .container:after { content: "\0020"; display: block; height: 0; clear: both; visibility: hidden; } - - /* Use clearfix class on parent to clear nested columns, - or wrap each row of columns in a
*/ - .clearfix:before, - .clearfix:after, - .row:before, - .row:after { - content: '\0020'; - display: block; - overflow: hidden; - visibility: hidden; - width: 0; - height: 0; } - .row:after, - .clearfix:after { - clear: both; } - .row, - .clearfix { - zoom: 1; } - - /* You can also use a
to clear columns */ - .clear { - clear: both; - display: block; - overflow: hidden; - visibility: hidden; - width: 0; - height: 0; - } diff --git a/lib/ref.js b/lib/ref.js index 77530a6..f44b5e3 100644 --- a/lib/ref.js +++ b/lib/ref.js @@ -11,7 +11,7 @@ exports = module.exports = require('bindings')('binding') * * ``` * console.log(ref.NULL); - * + * * ``` * * @name NULL @@ -36,7 +36,7 @@ exports = module.exports = require('bindings')('binding') * instance. Returns a JavaScript Number, which can't hold 64-bit integers, * so this function is unsafe on 64-bit systems. * ``` - * console.log(ref.address(new Buffer(1))); + * console.log(ref.address(Buffer.alloc(1))); * 4320233616 * * console.log(ref.address(ref.NULL))); @@ -54,7 +54,7 @@ exports = module.exports = require('bindings')('binding') * NULL pointer, _false_ otherwise. * * ``` - * console.log(ref.isNull(new Buffer(1))); + * console.log(ref.isNull(Buffer.alloc(1))); * false * * console.log(ref.isNull(ref.NULL)); @@ -67,70 +67,6 @@ exports = module.exports = require('bindings')('binding') * @type method */ -/** - * Reads a JavaScript Object that has previously been written to the given - * _buffer_ at the given _offset_. - * - * ``` - * var obj = { foo: 'bar' }; - * var buf = ref.alloc('Object', obj); - * - * var obj2 = ref.readObject(buf, 0); - * console.log(obj === obj2); - * true - * ``` - * - * @param {Buffer} buffer The buffer to read an Object from. - * @param {Number} offset The offset to begin reading from. - * @return {Object} The Object that was read from _buffer_. - * @name readObject - * @type method - */ - -/** - * Reads a Buffer instance from the given _buffer_ at the given _offset_. - * The _size_ parameter specifies the `length` of the returned Buffer instance, - * which defaults to __0__. - * - * ``` - * var buf = new Buffer('hello world'); - * var pointer = ref.alloc('pointer', buf); - * - * var buf2 = ref.readPointer(pointer, 0, buf.length); - * console.log(buf2.toString()); - * 'hello world' - * ``` - * - * @param {Buffer} buffer The buffer to read a Buffer from. - * @param {Number} offset The offset to begin reading from. - * @param {Number} length (optional) The length of the returned Buffer. Defaults to 0. - * @return {Buffer} The Buffer instance that was read from _buffer_. - * @name readPointer - * @type method - */ - -/** - * Returns a JavaScript String read from _buffer_ at the given _offset_. The - * C String is read until the first NULL byte, which indicates the end of the - * String. - * - * This function can read beyond the `length` of a Buffer. - * - * ``` - * var buf = new Buffer('hello\0world\0'); - * - * var str = ref.readCString(buf, 0); - * console.log(str); - * 'hello' - * ``` - * - * @param {Buffer} buffer The buffer to read a Buffer from. - * @param {Number} offset The offset to begin reading from. - * @return {String} The String that was read from _buffer_. - * @name readCString - * @type method - */ - /** * Returns a big-endian signed 64-bit int read from _buffer_ at the given * _offset_. @@ -139,7 +75,7 @@ exports = module.exports = require('bindings')('binding') * precision, then a Number is returned, otherwise a String is returned. * * ``` - * var buf = ref.alloc('int64'); + * var buf = Buffer.alloc(ref.sizeof.int64); * ref.writeInt64BE(buf, 0, '9223372036854775807'); * * var val = ref.readInt64BE(buf, 0) @@ -162,7 +98,7 @@ exports = module.exports = require('bindings')('binding') * precision, then a Number is returned, otherwise a String is returned. * * ``` - * var buf = ref.alloc('int64'); + * var buf = Buffer.alloc(ref.sizeof.int64); * ref.writeInt64LE(buf, 0, '9223372036854775807'); * * var val = ref.readInt64LE(buf, 0) @@ -185,7 +121,7 @@ exports = module.exports = require('bindings')('binding') * precision, then a Number is returned, otherwise a String is returned. * * ``` - * var buf = ref.alloc('uint64'); + * var buf = Buffer.alloc(ref.sizeof.uint64); * ref.writeUInt64BE(buf, 0, '18446744073709551615'); * * var val = ref.readUInt64BE(buf, 0) @@ -208,7 +144,7 @@ exports = module.exports = require('bindings')('binding') * precision, then a Number is returned, otherwise a String is returned. * * ``` - * var buf = ref.alloc('uint64'); + * var buf = Buffer.alloc(ref.sizeof.uint64); * ref.writeUInt64LE(buf, 0, '18446744073709551615'); * * var val = ref.readUInt64LE(buf, 0) @@ -228,7 +164,7 @@ exports = module.exports = require('bindings')('binding') * _buffer_ at the given _offset_. * * ``` - * var buf = ref.alloc('int64'); + * var buf = Buffer.alloc(ref.sizeof.int64); * ref.writeInt64BE(buf, 0, '9223372036854775807'); * ``` * @@ -244,7 +180,7 @@ exports = module.exports = require('bindings')('binding') * _buffer_ at the given _offset_. * * ``` - * var buf = ref.alloc('int64'); + * var buf = Buffer.alloc(ref.sizeof.int64); * ref.writeInt64LE(buf, 0, '9223372036854775807'); * ``` * @@ -260,7 +196,7 @@ exports = module.exports = require('bindings')('binding') * _buffer_ at the given _offset_. * * ``` - * var buf = ref.alloc('uint64'); + * var buf = Buffer.alloc(ref.sizeof.uint64); * ref.writeUInt64BE(buf, 0, '18446744073709551615'); * ``` * @@ -276,7 +212,7 @@ exports = module.exports = require('bindings')('binding') * into _buffer_ at the given _offset_. * * ``` - * var buf = ref.alloc('uint64'); + * var buf = Buffer.alloc(ref.sizeof.uint64); * ref.writeUInt64LE(buf, 0, '18446744073709551615'); * ``` * @@ -287,305 +223,14 @@ exports = module.exports = require('bindings')('binding') * @type method */ -/** - * Returns a new clone of the given "type" object, with its - * `indirection` level incremented by **1**. - * - * Say you wanted to create a type representing a `void *`: - * - * ``` - * var voidPtrType = ref.refType(ref.types.void); - * ``` - * - * @param {Object|String} type The "type" object to create a reference type from. Strings get coerced first. - * @return {Object} The new "type" object with its `indirection` incremented by 1. - */ - -exports.refType = function refType (type) { - var _type = exports.coerceType(type) - var rtn = Object.create(_type) - rtn.indirection++ - if (_type.name) { - Object.defineProperty(rtn, 'name', { - value: _type.name + '*', - configurable: true, - enumerable: true, - writable: true - }) - } - return rtn -} - -/** - * Returns a new clone of the given "type" object, with its - * `indirection` level decremented by 1. - * - * @param {Object|String} type The "type" object to create a dereference type from. Strings get coerced first. - * @return {Object} The new "type" object with its `indirection` decremented by 1. - */ - -exports.derefType = function derefType (type) { - var _type = exports.coerceType(type) - if (_type.indirection === 1) { - throw new Error('Cannot create deref\'d type for type with indirection 1') - } - var rtn = Object.getPrototypeOf(_type) - if (rtn.indirection !== _type.indirection - 1) { - // slow case - rtn = Object.create(_type) - rtn.indirection-- - } - return rtn -} - -/** - * Coerces a "type" object from a String or an actual "type" object. String values - * are looked up from the `ref.types` Object. So: - * - * * `"int"` gets coerced into `ref.types.int`. - * * `"int *"` gets translated into `ref.refType(ref.types.int)` - * * `ref.types.int` gets translated into `ref.types.int` (returns itself) - * - * Throws an Error if no valid "type" object could be determined. Most `ref` - * functions use this function under the hood, so anywhere a "type" object is - * expected, a String may be passed as well, including simply setting the - * `buffer.type` property. - * - * ``` - * var type = ref.coerceType('int **'); - * - * console.log(type.indirection); - * 3 - * ``` - * - * @param {Object|String} type The "type" Object or String to coerce. - * @return {Object} A "type" object - */ - -exports.coerceType = function coerceType (type) { - var rtn = type - if (typeof rtn === 'string') { - rtn = exports.types[type] - if (rtn) return rtn - - // strip whitespace - rtn = type.replace(/\s+/g, '').toLowerCase() - if (rtn === 'pointer') { - // legacy "pointer" being used :( - rtn = exports.refType(exports.types.void) // void * - } else if (rtn === 'string') { - rtn = exports.types.CString // special char * type - } else { - var refCount = 0 - rtn = rtn.replace(/\*/g, function () { - refCount++ - return '' - }) - // allow string names to be passed in - rtn = exports.types[rtn] - if (refCount > 0) { - if (!(rtn && 'size' in rtn && 'indirection' in rtn)) { - throw new TypeError('could not determine a proper "type" from: ' + JSON.stringify(type)) - } - for (var i = 0; i < refCount; i++) { - rtn = exports.refType(rtn) - } - } - } - } - if (!(rtn && 'size' in rtn && 'indirection' in rtn)) { - throw new TypeError('could not determine a proper "type" from: ' + JSON.stringify(type)) - } - return rtn -} - -/** - * Returns the "type" property of the given Buffer. - * Creates a default type for the buffer when none exists. - * - * @param {Buffer} buffer The Buffer instance to get the "type" object from. - * @return {Object} The "type" object from the given Buffer. - */ - -exports.getType = function getType (buffer) { - if (!buffer.type) { - debug('WARN: no "type" found on buffer, setting default "type"', buffer) - buffer.type = {} - buffer.type.size = buffer.length - buffer.type.indirection = 1 - buffer.type.get = function get () { - throw new Error('unknown "type"; cannot get()') - } - buffer.type.set = function set () { - throw new Error('unknown "type"; cannot set()') - } - } - return exports.coerceType(buffer.type) -} - -/** - * Calls the `get()` function of the Buffer's current "type" (or the - * passed in _type_ if present) at the given _offset_. - * - * This function handles checking the "indirection" level and returning a - * proper "dereferenced" Bufffer instance when necessary. - * - * @param {Buffer} buffer The Buffer instance to read from. - * @param {Number} offset (optional) The offset on the Buffer to start reading from. Defaults to 0. - * @param {Object|String} type (optional) The "type" object to use when reading. Defaults to calling `getType()` on the buffer. - * @return {?} Whatever value the "type" used when reading returns. - */ - -exports.get = function get (buffer, offset, type) { - if (!offset) { - offset = 0 - } - if (type) { - type = exports.coerceType(type) - } else { - type = exports.getType(buffer) - } - debug('get(): (offset: %d)', offset, buffer) - assert(type.indirection > 0, '"indirection" level must be at least 1') - if (type.indirection === 1) { - // need to check "type" - return type.get(buffer, offset) - } else { - // need to create a deref'd Buffer - var size = type.indirection === 2 ? type.size : exports.sizeof.pointer - var reference = exports.readPointer(buffer, offset, size) - reference.type = exports.derefType(type) - return reference - } -} - -/** - * Calls the `set()` function of the Buffer's current "type" (or the - * passed in _type_ if present) at the given _offset_. - * - * This function handles checking the "indirection" level writing a pointer rather - * than calling the `set()` function if the indirection is greater than 1. - * - * @param {Buffer} buffer The Buffer instance to write to. - * @param {Number} offset The offset on the Buffer to start writing to. - * @param {?} value The value to write to the Buffer instance. - * @param {Object|String} type (optional) The "type" object to use when reading. Defaults to calling `getType()` on the buffer. - */ - -exports.set = function set (buffer, offset, value, type) { - if (!offset) { - offset = 0 - } - if (type) { - type = exports.coerceType(type) - } else { - type = exports.getType(buffer) - } - debug('set(): (offset: %d)', offset, buffer, value) - assert(type.indirection >= 1, '"indirection" level must be at least 1') - if (type.indirection === 1) { - type.set(buffer, offset, value) - } else { - exports.writePointer(buffer, offset, value) - } -} - - -/** - * Returns a new Buffer instance big enough to hold `type`, - * with the given `value` written to it. - * - * ``` js - * var intBuf = ref.alloc(ref.types.int) - * var int_with_4 = ref.alloc(ref.types.int, 4) - * ``` - * - * @param {Object|String} type The "type" object to allocate. Strings get coerced first. - * @param {?} value (optional) The initial value set on the returned Buffer, using _type_'s `set()` function. - * @return {Buffer} A new Buffer instance with it's `type` set to "type", and (optionally) "value" written to it. - */ - -exports.alloc = function alloc (_type, value) { - var type = exports.coerceType(_type) - debug('allocating Buffer for type with "size"', type.size) - var size - if (type.indirection === 1) { - size = type.size - } else { - size = exports.sizeof.pointer - } - var buffer = new Buffer(size) - buffer.type = type - if (arguments.length >= 2) { - debug('setting value on allocated buffer', value) - exports.set(buffer, 0, value, type) - } - return buffer -} - -/** - * Returns a new `Buffer` instance with the given String written to it with the - * given encoding (defaults to __'utf8'__). The buffer is 1 byte longer than the - * string itself, and is NUL terminated. - * - * ``` - * var buf = ref.allocCString('hello world'); - * - * console.log(buf.toString()); - * 'hello world\u0000' - * ``` - * - * @param {String} string The JavaScript string to be converted to a C string. - * @param {String} encoding (optional) The encoding to use for the C string. Defaults to __'utf8'__. - * @return {Buffer} The new `Buffer` instance with the specified String wrtten to it, and a trailing NUL byte. - */ - -exports.allocCString = function allocCString (string, encoding) { - if (null == string || (Buffer.isBuffer(string) && exports.isNull(string))) { - return exports.NULL - } - var size = Buffer.byteLength(string, encoding) + 1 - var buffer = new Buffer(size) - exports.writeCString(buffer, 0, string, encoding) - buffer.type = charPtrType - return buffer -} - -/** - * Writes the given string as a C String (NULL terminated) to the given buffer - * at the given offset. "encoding" is optional and defaults to __'utf8'__. - * - * Unlike `readCString()`, this function requires the buffer to actually have the - * proper length. - * - * @param {Buffer} buffer The Buffer instance to write to. - * @param {Number} offset The offset of the buffer to begin writing at. - * @param {String} string The JavaScript String to write that will be written to the buffer. - * @param {String} encoding (optional) The encoding to read the C string as. Defaults to __'utf8'__. - */ - -exports.writeCString = function writeCString (buffer, offset, string, encoding) { - assert(Buffer.isBuffer(buffer), 'expected a Buffer as the first argument') - assert.equal('string', typeof string, 'expected a "string" as the third argument') - if (!offset) { - offset = 0 - } - if (!encoding) { - encoding = 'utf8' - } - var size = buffer.length - offset - var len = buffer.write(string, offset, size, encoding) - buffer.writeUInt8(0, offset + len) // NUL terminate -} - exports['readInt64' + exports.endianness] = exports.readInt64 exports['readUInt64' + exports.endianness] = exports.readUInt64 exports['writeInt64' + exports.endianness] = exports.writeInt64 exports['writeUInt64' + exports.endianness] = exports.writeUInt64 var opposite = exports.endianness == 'LE' ? 'BE' : 'LE' -var int64temp = new Buffer(exports.sizeof.int64) -var uint64temp = new Buffer(exports.sizeof.uint64) +var int64temp = Buffer.alloc(exports.sizeof.int64) +var uint64temp = Buffer.alloc(exports.sizeof.uint64) exports['readInt64' + opposite] = function (buffer, offset) { for (var i = 0; i < exports.sizeof.int64; i++) { @@ -612,221 +257,6 @@ exports['writeUInt64' + opposite] = function (buffer, offset, value) { } } -/** - * `ref()` accepts a Buffer instance and returns a new Buffer - * instance that is "pointer" sized and has its data pointing to the given - * Buffer instance. Essentially the created Buffer is a "reference" to the - * original pointer, equivalent to the following C code: - * - * ``` c - * char *buf = buffer; - * char **ref = &buf; - * ``` - * - * @param {Buffer} buffer A Buffer instance to create a reference to. - * @return {Buffer} A new Buffer instance pointing to _buffer_. - */ - -exports.ref = function ref (buffer) { - debug('creating a reference to buffer', buffer) - var type = exports.refType(exports.getType(buffer)) - return exports.alloc(type, buffer) -} - -/** - * Accepts a Buffer instance and attempts to "dereference" it. - * That is, first it checks the `indirection` count of _buffer_'s "type", and if - * it's greater than __1__ then it merely returns another Buffer, but with one - * level less `indirection`. - * - * When _buffer_'s indirection is at __1__, then it checks for `buffer.type` - * which should be an Object with its own `get()` function. - * - * ``` - * var buf = ref.alloc('int', 6); - * - * var val = ref.deref(buf); - * console.log(val); - * 6 - * ``` - * - * - * @param {Buffer} buffer A Buffer instance to dereference. - * @return {?} The returned value after dereferencing _buffer_. - */ - -exports.deref = function deref (buffer) { - debug('dereferencing buffer', buffer) - return exports.get(buffer) -} - -/** - * Attaches _object_ to _buffer_ such that it prevents _object_ from being garbage - * collected until _buffer_ does. - * - * @param {Buffer} buffer A Buffer instance to attach _object_ to. - * @param {Object|Buffer} object An Object or Buffer to prevent from being garbage collected until _buffer_ does. - * @api private - */ - -exports._attach = function _attach (buf, obj) { - if (!buf._refs) { - buf._refs = [] - } - buf._refs.push(obj) -} - -/** - * Same as `ref.writeObject()`, except that this version does not _attach_ the - * Object to the Buffer, which is potentially unsafe if the garbage collector - * runs. - * - * @param {Buffer} buffer A Buffer instance to write _object_ to. - * @param {Number} offset The offset on the Buffer to start writing at. - * @param {Object} object The Object to be written into _buffer_. - * @api private - */ - -exports._writeObject = exports.writeObject - -/** - * Writes a pointer to _object_ into _buffer_ at the specified _offset. - * - * This function "attaches" _object_ to _buffer_ to prevent it from being garbage - * collected. - * - * ``` - * var buf = ref.alloc('Object'); - * ref.writeObject(buf, 0, { foo: 'bar' }); - * - * ``` - * - * @param {Buffer} buffer A Buffer instance to write _object_ to. - * @param {Number} offset The offset on the Buffer to start writing at. - * @param {Object} object The Object to be written into _buffer_. - */ - -exports.writeObject = function writeObject (buf, offset, obj, persistent) { - debug('writing Object to buffer', buf, offset, obj, persistent) - exports._writeObject(buf, offset, obj, persistent) - exports._attach(buf, obj) -} - -/** - * Same as `ref.writePointer()`, except that this version does not attach - * _pointer_ to _buffer_, which is potentially unsafe if the garbage collector - * runs. - * - * @param {Buffer} buffer A Buffer instance to write _pointer to. - * @param {Number} offset The offset on the Buffer to start writing at. - * @param {Buffer} pointer The Buffer instance whose memory address will be written to _buffer_. - * @api private - */ - -exports._writePointer = exports.writePointer - -/** - * Writes the memory address of _pointer_ to _buffer_ at the specified _offset_. - * - * This function "attaches" _object_ to _buffer_ to prevent it from being garbage - * collected. - * - * ``` - * var someBuffer = new Buffer('whatever'); - * var buf = ref.alloc('pointer'); - * ref.writePointer(buf, 0, someBuffer); - * ``` - * - * @param {Buffer} buffer A Buffer instance to write _pointer to. - * @param {Number} offset The offset on the Buffer to start writing at. - * @param {Buffer} pointer The Buffer instance whose memory address will be written to _buffer_. - */ - -exports.writePointer = function writePointer (buf, offset, ptr) { - debug('writing pointer to buffer', buf, offset, ptr) - exports._writePointer(buf, offset, ptr) - exports._attach(buf, ptr) -} - -/** - * Same as `ref.reinterpret()`, except that this version does not attach - * _buffer_ to the returned Buffer, which is potentially unsafe if the - * garbage collector runs. - * - * @param {Buffer} buffer A Buffer instance to base the returned Buffer off of. - * @param {Number} size The `length` property of the returned Buffer. - * @param {Number} offset The offset of the Buffer to begin from. - * @return {Buffer} A new Buffer instance with the same memory address as _buffer_, and the requested _size_. - * @api private - */ - -exports._reinterpret = exports.reinterpret - -/** - * Returns a new Buffer instance with the specified _size_, with the same memory - * address as _buffer_. - * - * This function "attaches" _buffer_ to the returned Buffer to prevent it from - * being garbage collected. - * - * @param {Buffer} buffer A Buffer instance to base the returned Buffer off of. - * @param {Number} size The `length` property of the returned Buffer. - * @param {Number} offset The offset of the Buffer to begin from. - * @return {Buffer} A new Buffer instance with the same memory address as _buffer_, and the requested _size_. - */ - -exports.reinterpret = function reinterpret (buffer, size, offset) { - debug('reinterpreting buffer to "%d" bytes', size) - var rtn = exports._reinterpret(buffer, size, offset || 0) - exports._attach(rtn, buffer) - return rtn -} - -/** - * Same as `ref.reinterpretUntilZeros()`, except that this version does not - * attach _buffer_ to the returned Buffer, which is potentially unsafe if the - * garbage collector runs. - * - * @param {Buffer} buffer A Buffer instance to base the returned Buffer off of. - * @param {Number} size The number of sequential, aligned `NULL` bytes that are required to terminate the buffer. - * @param {Number} offset The offset of the Buffer to begin from. - * @return {Buffer} A new Buffer instance with the same memory address as _buffer_, and a variable `length` that is terminated by _size_ NUL bytes. - * @api private - */ - -exports._reinterpretUntilZeros = exports.reinterpretUntilZeros - -/** - * Accepts a `Buffer` instance and a number of `NULL` bytes to read from the - * pointer. This function will scan past the boundary of the Buffer's `length` - * until it finds `size` number of aligned `NULL` bytes. - * - * This is useful for finding the end of NUL-termintated array or C string. For - * example, the `readCString()` function _could_ be implemented like: - * - * ``` - * function readCString (buf) { - * return ref.reinterpretUntilZeros(buf, 1).toString('utf8') - * } - * ``` - * - * This function "attaches" _buffer_ to the returned Buffer to prevent it from - * being garbage collected. - * - * @param {Buffer} buffer A Buffer instance to base the returned Buffer off of. - * @param {Number} size The number of sequential, aligned `NULL` bytes are required to terminate the buffer. - * @param {Number} offset The offset of the Buffer to begin from. - * @return {Buffer} A new Buffer instance with the same memory address as _buffer_, and a variable `length` that is terminated by _size_ NUL bytes. - */ - -exports.reinterpretUntilZeros = function reinterpretUntilZeros (buffer, size, offset) { - debug('reinterpreting buffer to until "%d" NULL (0) bytes are found', size) - var rtn = exports._reinterpretUntilZeros(buffer, size, offset || 0) - exports._attach(rtn, buffer) - return rtn -} - - // the built-in "types" var types = exports.types = {} @@ -837,15 +267,15 @@ var types = exports.types = {} */ types.void = { - size: 0 + size: 0 , indirection: 1 - , get: function get (buf, offset) { - debug('getting `void` type (returns `null`)') - return null - } - , set: function set (buf, offset, val) { - debug('setting `void` type (no-op)') - } + , get: function get(buf, offset) { + debug('getting `void` type (returns `null`)') + return null + } + , set: function set(buf, offset, val) { + debug('setting `void` type (no-op)') + } } /** @@ -853,17 +283,17 @@ types.void = { */ types.int8 = { - size: exports.sizeof.int8 + size: exports.sizeof.int8 , indirection: 1 - , get: function get (buf, offset) { - return buf.readInt8(offset || 0) - } - , set: function set (buf, offset, val) { - if (typeof val === 'string') { - val = val.charCodeAt(0) - } - return buf.writeInt8(val, offset || 0) + , get: function get(buf, offset) { + return buf.readInt8(offset || 0) + } + , set: function set(buf, offset, val) { + if (typeof val === 'string') { + val = val.charCodeAt(0) } + return buf.writeInt8(val, offset || 0) + } } /** @@ -871,17 +301,17 @@ types.int8 = { */ types.uint8 = { - size: exports.sizeof.uint8 + size: exports.sizeof.uint8 , indirection: 1 - , get: function get (buf, offset) { - return buf.readUInt8(offset || 0) - } - , set: function set (buf, offset, val) { - if (typeof val === 'string') { - val = val.charCodeAt(0) - } - return buf.writeUInt8(val, offset || 0) + , get: function get(buf, offset) { + return buf.readUInt8(offset || 0) + } + , set: function set(buf, offset, val) { + if (typeof val === 'string') { + val = val.charCodeAt(0) } + return buf.writeUInt8(val, offset || 0) + } } /** @@ -889,14 +319,14 @@ types.uint8 = { */ types.int16 = { - size: exports.sizeof.int16 + size: exports.sizeof.int16 , indirection: 1 - , get: function get (buf, offset) { - return buf['readInt16' + exports.endianness](offset || 0) - } - , set: function set (buf, offset, val) { - return buf['writeInt16' + exports.endianness](val, offset || 0) - } + , get: function get(buf, offset) { + return buf['readInt16' + exports.endianness](offset || 0) + } + , set: function set(buf, offset, val) { + return buf['writeInt16' + exports.endianness](val, offset || 0) + } } /** @@ -904,14 +334,14 @@ types.int16 = { */ types.uint16 = { - size: exports.sizeof.uint16 + size: exports.sizeof.uint16 , indirection: 1 - , get: function get (buf, offset) { - return buf['readUInt16' + exports.endianness](offset || 0) - } - , set: function set (buf, offset, val) { - return buf['writeUInt16' + exports.endianness](val, offset || 0) - } + , get: function get(buf, offset) { + return buf['readUInt16' + exports.endianness](offset || 0) + } + , set: function set(buf, offset, val) { + return buf['writeUInt16' + exports.endianness](val, offset || 0) + } } /** @@ -919,14 +349,14 @@ types.uint16 = { */ types.int32 = { - size: exports.sizeof.int32 + size: exports.sizeof.int32 , indirection: 1 - , get: function get (buf, offset) { - return buf['readInt32' + exports.endianness](offset || 0) - } - , set: function set (buf, offset, val) { - return buf['writeInt32' + exports.endianness](val, offset || 0) - } + , get: function get(buf, offset) { + return buf['readInt32' + exports.endianness](offset || 0) + } + , set: function set(buf, offset, val) { + return buf['writeInt32' + exports.endianness](val, offset || 0) + } } /** @@ -934,14 +364,14 @@ types.int32 = { */ types.uint32 = { - size: exports.sizeof.uint32 + size: exports.sizeof.uint32 , indirection: 1 - , get: function get (buf, offset) { - return buf['readUInt32' + exports.endianness](offset || 0) - } - , set: function set (buf, offset, val) { - return buf['writeUInt32' + exports.endianness](val, offset || 0) - } + , get: function get(buf, offset) { + return buf['readUInt32' + exports.endianness](offset || 0) + } + , set: function set(buf, offset, val) { + return buf['writeUInt32' + exports.endianness](val, offset || 0) + } } /** @@ -949,14 +379,14 @@ types.uint32 = { */ types.int64 = { - size: exports.sizeof.int64 + size: exports.sizeof.int64 , indirection: 1 - , get: function get (buf, offset) { - return buf['readInt64' + exports.endianness](offset || 0) - } - , set: function set (buf, offset, val) { - return buf['writeInt64' + exports.endianness](val, offset || 0) - } + , get: function get(buf, offset) { + return buf['readInt64' + exports.endianness](offset || 0) + } + , set: function set(buf, offset, val) { + return buf['writeInt64' + exports.endianness](val, offset || 0) + } } /** @@ -964,14 +394,14 @@ types.int64 = { */ types.uint64 = { - size: exports.sizeof.uint64 + size: exports.sizeof.uint64 , indirection: 1 - , get: function get (buf, offset) { - return buf['readUInt64' + exports.endianness](offset || 0) - } - , set: function set (buf, offset, val) { - return buf['writeUInt64' + exports.endianness](val, offset || 0) - } + , get: function get(buf, offset) { + return buf['readUInt64' + exports.endianness](offset || 0) + } + , set: function set(buf, offset, val) { + return buf['writeUInt64' + exports.endianness](val, offset || 0) + } } /** @@ -979,14 +409,14 @@ types.uint64 = { */ types.float = { - size: exports.sizeof.float + size: exports.sizeof.float , indirection: 1 - , get: function get (buf, offset) { - return buf['readFloat' + exports.endianness](offset || 0) - } - , set: function set (buf, offset, val) { - return buf['writeFloat' + exports.endianness](val, offset || 0) - } + , get: function get(buf, offset) { + return buf['readFloat' + exports.endianness](offset || 0) + } + , set: function set(buf, offset, val) { + return buf['writeFloat' + exports.endianness](val, offset || 0) + } } /** @@ -994,183 +424,120 @@ types.float = { */ types.double = { - size: exports.sizeof.double - , indirection: 1 - , get: function get (buf, offset) { - return buf['readDouble' + exports.endianness](offset || 0) - } - , set: function set (buf, offset, val) { - return buf['writeDouble' + exports.endianness](val, offset || 0) - } -} - -/** - * The `Object` type. This can be used to read/write regular JS Objects - * into raw memory. - */ - -types.Object = { - size: exports.sizeof.Object - , indirection: 1 - , get: function get (buf, offset) { - return buf.readObject(offset || 0) - } - , set: function set (buf, offset, val) { - return buf.writeObject(val, offset || 0) - } -} - -/** - * The `CString` (a.k.a `"string"`) type. - * - * CStrings are a kind of weird thing. We say it's `sizeof(char *)`, and - * `indirection` level of 1, which means that we have to return a Buffer that - * is pointer sized, and points to a some utf8 string data, so we have to create - * a 2nd "in-between" buffer. - */ - -types.CString = { - size: exports.sizeof.pointer - , alignment: exports.alignof.pointer + size: exports.sizeof.double , indirection: 1 - , get: function get (buf, offset) { - var _buf = exports.readPointer(buf, offset) - if (exports.isNull(_buf)) { - return null - } - return exports.readCString(_buf, 0) - } - , set: function set (buf, offset, val) { - var _buf - if (Buffer.isBuffer(val)) { - _buf = val - } else { - // assume string - _buf = exports.allocCString(val) - } - return exports.writePointer(buf, offset, _buf) - } + , get: function get(buf, offset) { + return buf['readDouble' + exports.endianness](offset || 0) + } + , set: function set(buf, offset, val) { + return buf['writeDouble' + exports.endianness](val, offset || 0) + } } + /** + * The `bool` type. + * + * Wrapper type around `types.uint8` that accepts/returns `true` or + * `false` Boolean JavaScript values. + * + * @name bool + * + */ -// alias Utf8String -var utfstringwarned = false -Object.defineProperty(types, 'Utf8String', { - enumerable: false - , configurable: true - , get: function () { - if (!utfstringwarned) { - utfstringwarned = true - console.error('"Utf8String" type is deprecated, use "CString" instead') - } - return types.CString - } -}) - -/** - * The `bool` type. - * - * Wrapper type around `types.uint8` that accepts/returns `true` or - * `false` Boolean JavaScript values. - * - * @name bool - * - */ - -/** - * The `byte` type. - * - * @name byte - */ + /** + * The `byte` type. + * + * @name byte + */ -/** - * The `char` type. - * - * @name char - */ + /** + * The `char` type. + * + * @name char + */ -/** - * The `uchar` type. - * - * @name uchar - */ + /** + * The `uchar` type. + * + * @name uchar + */ -/** - * The `short` type. - * - * @name short - */ + /** + * The `short` type. + * + * @name short + */ -/** - * The `ushort` type. - * - * @name ushort - */ + /** + * The `ushort` type. + * + * @name ushort + */ -/** - * The `int` type. - * - * @name int - */ + /** + * The `int` type. + * + * @name int + */ -/** - * The `uint` type. - * - * @name uint - */ + /** + * The `uint` type. + * + * @name uint + */ -/** - * The `long` type. - * - * @name long - */ + /** + * The `long` type. + * + * @name long + */ -/** - * The `ulong` type. - * - * @name ulong - */ + /** + * The `ulong` type. + * + * @name ulong + */ -/** - * The `longlong` type. - * - * @name longlong - */ + /** + * The `longlong` type. + * + * @name longlong + */ -/** - * The `ulonglong` type. - * - * @name ulonglong - */ + /** + * The `ulonglong` type. + * + * @name ulonglong + */ -/** - * The `size_t` type. - * - * @name size_t - */ + /** + * The `size_t` type. + * + * @name size_t + */ -/** - * The `wchar_t` type. - * - * @name wchar_t - */ + /** + * The `wchar_t` type. + * + * @name wchar_t + */ -// "typedef"s for the variable-sized types -;[ 'bool', 'byte', 'char', 'uchar', 'short', 'ushort', 'int', 'uint', 'long' -, 'ulong', 'longlong', 'ulonglong', 'size_t', 'wchar_t' ].forEach(function (name) { - var unsigned = name === 'bool' - || name === 'byte' - || name === 'size_t' - || name[0] === 'u' - var size = exports.sizeof[name] - assert(size >= 1 && size <= 8) - var typeName = 'int' + (size * 8) - if (unsigned) { - typeName = 'u' + typeName - } - var type = exports.types[typeName] - assert(type) - exports.types[name] = Object.create(type) -}) + // "typedef"s for the variable-sized types + ;['bool', 'byte', 'char', 'uchar', 'short', 'ushort', 'int', 'uint', 'long' + , 'ulong', 'longlong', 'ulonglong', 'size_t', 'wchar_t'].forEach(function (name) { + var unsigned = name === 'bool' + || name === 'byte' + || name === 'size_t' + || name[0] === 'u' + var size = exports.sizeof[name] + assert(size >= 1 && size <= 8) + var typeName = 'int' + (size * 8) + if (unsigned) { + typeName = 'u' + typeName + } + var type = exports.types[typeName] + assert(type) + exports.types[name] = Object.create(type) + }) // set the "alignment" property on the built-in types Object.keys(exports.alignof).forEach(function (name) { @@ -1181,12 +548,12 @@ Object.keys(exports.alignof).forEach(function (name) { // make the `bool` type work with JS true/false values exports.types.bool.get = (function (_get) { - return function get (buf, offset) { + return function get(buf, offset) { return _get(buf, offset) ? true : false } })(exports.types.bool.get) exports.types.bool.set = (function (_set) { - return function set (buf, offset, val) { + return function set(buf, offset, val) { if (typeof val !== 'number') { val = val ? 1 : 0 } @@ -1202,39 +569,19 @@ Object.keys(exports.types).forEach(function (name) { exports.types[name].name = name }) -/*! - * This `char *` type is used by "allocCString()" above. - */ - -var charPtrType = exports.refType(exports.types.char) - /*! * Set the `type` property of the `NULL` pointer Buffer object. */ exports.NULL.type = exports.types.void -/** - * `NULL_POINTER` is a pointer-sized `Buffer` instance pointing to `NULL`. - * Conceptually, it's equivalent to the following C code: - * - * ``` c - * char *null_pointer; - * null_pointer = NULL; - * ``` - * - * @type Buffer - */ - -exports.NULL_POINTER = exports.ref(exports.NULL) - /** * All these '...' comment blocks below are for the documentation generator. * * @section buffer */ -Buffer.prototype.address = function address () { +Buffer.prototype.address = function address() { return exports.address(this, 0) } @@ -1242,7 +589,7 @@ Buffer.prototype.address = function address () { * ... */ -Buffer.prototype.hexAddress = function hexAddress () { +Buffer.prototype.hexAddress = function hexAddress() { return exports.hexAddress(this, 0) } @@ -1250,79 +597,11 @@ Buffer.prototype.hexAddress = function hexAddress () { * ... */ -Buffer.prototype.isNull = function isNull () { +Buffer.prototype.isNull = function isNull() { return exports.isNull(this, 0) } -/** - * ... - */ - -Buffer.prototype.ref = function ref () { - return exports.ref(this) -} - -/** - * ... - */ - -Buffer.prototype.deref = function deref () { - return exports.deref(this) -} - -/** - * ... - */ - -Buffer.prototype.readObject = function readObject (offset) { - return exports.readObject(this, offset) -} - -/** - * ... - */ - -Buffer.prototype.writeObject = function writeObject (obj, offset) { - return exports.writeObject(this, offset, obj) -} - -/** - * ... - */ - -Buffer.prototype.readPointer = function readPointer (offset, size) { - return exports.readPointer(this, offset, size) -} - -/** - * ... - */ - -Buffer.prototype.writePointer = function writePointer (ptr, offset) { - return exports.writePointer(this, offset, ptr) -} - -/** - * ... - */ - -Buffer.prototype.readCString = function readCString (offset) { - return exports.readCString(this, offset) -} - -/** - * ... - */ - -Buffer.prototype.writeCString = function writeCString (string, offset, encoding) { - return exports.writeCString(this, offset, string, encoding) -} - -/** - * ... - */ - -Buffer.prototype.readInt64BE = function readInt64BE (offset) { +Buffer.prototype.readInt64BE = function readInt64BE(offset) { return exports.readInt64BE(this, offset) } @@ -1330,7 +609,7 @@ Buffer.prototype.readInt64BE = function readInt64BE (offset) { * ... */ -Buffer.prototype.writeInt64BE = function writeInt64BE (val, offset) { +Buffer.prototype.writeInt64BE = function writeInt64BE(val, offset) { return exports.writeInt64BE(this, offset, val) } @@ -1338,7 +617,7 @@ Buffer.prototype.writeInt64BE = function writeInt64BE (val, offset) { * ... */ -Buffer.prototype.readUInt64BE = function readUInt64BE (offset) { +Buffer.prototype.readUInt64BE = function readUInt64BE(offset) { return exports.readUInt64BE(this, offset) } @@ -1346,7 +625,7 @@ Buffer.prototype.readUInt64BE = function readUInt64BE (offset) { * ... */ -Buffer.prototype.writeUInt64BE = function writeUInt64BE (val, offset) { +Buffer.prototype.writeUInt64BE = function writeUInt64BE(val, offset) { return exports.writeUInt64BE(this, offset, val) } @@ -1354,7 +633,7 @@ Buffer.prototype.writeUInt64BE = function writeUInt64BE (val, offset) { * ... */ -Buffer.prototype.readInt64LE = function readInt64LE (offset) { +Buffer.prototype.readInt64LE = function readInt64LE(offset) { return exports.readInt64LE(this, offset) } @@ -1362,7 +641,7 @@ Buffer.prototype.readInt64LE = function readInt64LE (offset) { * ... */ -Buffer.prototype.writeInt64LE = function writeInt64LE (val, offset) { +Buffer.prototype.writeInt64LE = function writeInt64LE(val, offset) { return exports.writeInt64LE(this, offset, val) } @@ -1370,7 +649,7 @@ Buffer.prototype.writeInt64LE = function writeInt64LE (val, offset) { * ... */ -Buffer.prototype.readUInt64LE = function readUInt64LE (offset) { +Buffer.prototype.readUInt64LE = function readUInt64LE(offset) { return exports.readUInt64LE(this, offset) } @@ -1378,26 +657,10 @@ Buffer.prototype.readUInt64LE = function readUInt64LE (offset) { * ... */ -Buffer.prototype.writeUInt64LE = function writeUInt64LE (val, offset) { +Buffer.prototype.writeUInt64LE = function writeUInt64LE(val, offset) { return exports.writeUInt64LE(this, offset, val) } -/** - * ... - */ - -Buffer.prototype.reinterpret = function reinterpret (size, offset) { - return exports.reinterpret(this, size, offset) -} - -/** - * ... - */ - -Buffer.prototype.reinterpretUntilZeros = function reinterpretUntilZeros (size, offset) { - return exports.reinterpretUntilZeros(this, size, offset) -} - /** * `ref` overwrites the default `Buffer#inspect()` function to include the * hex-encoded memory address of the Buffer instance when invoked. @@ -1407,14 +670,14 @@ Buffer.prototype.reinterpretUntilZeros = function reinterpretUntilZeros (size, o * **Before**: * * ``` js - * console.log(new Buffer('ref')); + * console.log(Buffer.from('ref')); * * ``` * * **After**: * * ``` js - * console.log(new Buffer('ref')); + * console.log(Buffer.from('ref')); * * ``` */ @@ -1424,56 +687,15 @@ var inspectSym = inspect.custom || 'inspect' * in node 6.91, inspect.custom does not give a correct value; so in this case, don't torch the whole process. * fixed in >6.9.2 */ -if (Buffer.prototype[inspectSym]){ +if (Buffer.prototype[inspectSym]) { Buffer.prototype[inspectSym] = overwriteInspect(Buffer.prototype[inspectSym]) } - -// does SlowBuffer inherit from Buffer? (node >= v0.7.9) -if (!(exports.NULL instanceof Buffer)) { - debug('extending SlowBuffer\'s prototype since it doesn\'t inherit from Buffer.prototype') - - /*! - * SlowBuffer convenience methods. - */ - - var SlowBuffer = require('buffer').SlowBuffer - - SlowBuffer.prototype.address = Buffer.prototype.address - SlowBuffer.prototype.hexAddress = Buffer.prototype.hexAddress - SlowBuffer.prototype.isNull = Buffer.prototype.isNull - SlowBuffer.prototype.ref = Buffer.prototype.ref - SlowBuffer.prototype.deref = Buffer.prototype.deref - SlowBuffer.prototype.readObject = Buffer.prototype.readObject - SlowBuffer.prototype.writeObject = Buffer.prototype.writeObject - SlowBuffer.prototype.readPointer = Buffer.prototype.readPointer - SlowBuffer.prototype.writePointer = Buffer.prototype.writePointer - SlowBuffer.prototype.readCString = Buffer.prototype.readCString - SlowBuffer.prototype.writeCString = Buffer.prototype.writeCString - SlowBuffer.prototype.reinterpret = Buffer.prototype.reinterpret - SlowBuffer.prototype.reinterpretUntilZeros = Buffer.prototype.reinterpretUntilZeros - SlowBuffer.prototype.readInt64BE = Buffer.prototype.readInt64BE - SlowBuffer.prototype.writeInt64BE = Buffer.prototype.writeInt64BE - SlowBuffer.prototype.readUInt64BE = Buffer.prototype.readUInt64BE - SlowBuffer.prototype.writeUInt64BE = Buffer.prototype.writeUInt64BE - SlowBuffer.prototype.readInt64LE = Buffer.prototype.readInt64LE - SlowBuffer.prototype.writeInt64LE = Buffer.prototype.writeInt64LE - SlowBuffer.prototype.readUInt64LE = Buffer.prototype.readUInt64LE - SlowBuffer.prototype.writeUInt64LE = Buffer.prototype.writeUInt64LE -/** - * in node 6.9.1, inspect.custom does not give a correct value; so in this case, don't torch the whole process. - * fixed in >6.9.2 - */ - if (SlowBuffer.prototype[inspectSym]){ - SlowBuffer.prototype[inspectSym] = overwriteInspect(SlowBuffer.prototype[inspectSym]) - } -} - -function overwriteInspect (inspect) { +function overwriteInspect(inspect) { if (inspect.name === 'refinspect') { return inspect } else { - return function refinspect () { + return function refinspect() { var v = inspect.apply(this, arguments) return v.replace('Buffer', 'Buffer@0x' + this.hexAddress()) } diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..0a0f18f --- /dev/null +++ b/package-lock.json @@ -0,0 +1,816 @@ +{ + "name": "ref", + "version": "1.3.5", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "ansi-colors": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", + "integrity": "sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==", + "dev": true + }, + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "requires": { + "file-uri-to-path": "1.0.0" + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "dependencies": { + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "cliui": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", + "dev": true, + "requires": { + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, + "requires": { + "object-keys": "^1.0.12" + } + }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "es-abstract": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.15.0.tgz", + "integrity": "sha512-bhkEqWJ2t2lMeaJDuk7okMkJWI/yqgH/EoGwpcvv0XW9RWQsRspI4wt6xuyuvMvvQE3gg/D9HXppgk21w78GyQ==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.0", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.0", + "is-callable": "^1.1.4", + "is-regex": "^1.0.4", + "object-inspect": "^1.6.0", + "object-keys": "^1.1.1", + "string.prototype.trimleft": "^2.1.0", + "string.prototype.trimright": "^2.1.0" + } + }, + "es-to-primitive": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", + "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "flat": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", + "integrity": "sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw==", + "dev": true, + "requires": { + "is-buffer": "~2.0.3" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "has-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", + "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", + "dev": true + }, + "he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "is-buffer": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", + "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==", + "dev": true + }, + "is-callable": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", + "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", + "dev": true + }, + "is-date-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", + "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "is-regex": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", + "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", + "dev": true, + "requires": { + "has": "^1.0.1" + } + }, + "is-symbol": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", + "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", + "dev": true, + "requires": { + "has-symbols": "^1.0.0" + } + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "dev": true + }, + "log-symbols": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", + "integrity": "sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg==", + "dev": true, + "requires": { + "chalk": "^2.0.1" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "mocha": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-6.2.1.tgz", + "integrity": "sha512-VCcWkLHwk79NYQc8cxhkmI8IigTIhsCwZ6RTxQsqK6go4UvEhzJkYuHm8B2YtlSxcYq2fY+ucr4JBwoD6ci80A==", + "dev": true, + "requires": { + "ansi-colors": "3.2.3", + "browser-stdout": "1.3.1", + "debug": "3.2.6", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "find-up": "3.0.0", + "glob": "7.1.3", + "growl": "1.10.5", + "he": "1.2.0", + "js-yaml": "3.13.1", + "log-symbols": "2.2.0", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "ms": "2.1.1", + "node-environment-flags": "1.0.5", + "object.assign": "4.1.0", + "strip-json-comments": "2.0.1", + "supports-color": "6.0.0", + "which": "1.3.1", + "wide-align": "1.1.3", + "yargs": "13.3.0", + "yargs-parser": "13.1.1", + "yargs-unparser": "1.6.0" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + } + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "nan": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==" + }, + "node-environment-flags": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.5.tgz", + "integrity": "sha512-VNYPRfGfmZLx0Ye20jWzHUjyTW/c+6Wq+iLhDzUI4XmhrDd9l/FozXV3F2xOaXjvp0co0+v1YSR3CMP6g+VvLQ==", + "dev": true, + "requires": { + "object.getownpropertydescriptors": "^2.0.3", + "semver": "^5.7.0" + } + }, + "object-inspect": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.6.0.tgz", + "integrity": "sha512-GJzfBZ6DgDAmnuaM3104jR4s1Myxr3Y3zfIyN4z3UdqN69oSRacNK8UhnobDdC+7J2AHCjGwxQubNJfE70SXXQ==", + "dev": true + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true + }, + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } + }, + "object.getownpropertydescriptors": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz", + "integrity": "sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY=", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.5.1" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "p-limit": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz", + "integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "string.prototype.trimleft": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.0.tgz", + "integrity": "sha512-FJ6b7EgdKxxbDxc79cOlok6Afd++TTs5szo+zJTUyow3ycrRfJVE2pq3vcN53XexvKZu/DJMDfeI/qMiZTrjTw==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + }, + "string.prototype.trimright": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.0.tgz", + "integrity": "sha512-fXZTSV55dNBwv16uw+hh5jkghxSnc5oHq+5K/gXgizHwAvMetdAJlHqqoFC1FSDVPYWLkAKl2cxpUT41sV7nSg==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, + "supports-color": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.0.0.tgz", + "integrity": "sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true + }, + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "dev": true, + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "wrap-ansi": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "dev": true + }, + "yargs": { + "version": "13.3.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.0.tgz", + "integrity": "sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA==", + "dev": true, + "requires": { + "cliui": "^5.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.1.1" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "yargs-parser": { + "version": "13.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz", + "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + }, + "yargs-unparser": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.6.0.tgz", + "integrity": "sha512-W9tKgmSn0DpSatfri0nx52Joq5hVXgeLiqR/5G0sZNDoLZFOr/xjBUDcShCOGNsBnEMNo1KAMBkTej1Hm62HTw==", + "dev": true, + "requires": { + "flat": "^4.1.0", + "lodash": "^4.17.15", + "yargs": "^13.3.0" + } + } + } +} diff --git a/package.json b/package.json index 503e10b..f8d04d2 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,11 @@ { "name": "ref", - "description": "Turn Buffer instances into \"pointers\"", + "description": "Adds int64 support to Buffer instances", "keywords": [ "native", "buffer", "extensions", "c++", - "pointer", - "reference", - "dereference", "type", "int", "long", @@ -26,8 +23,7 @@ }, "main": "./lib/ref.js", "scripts": { - "docs": "node docs/compile", - "test": "mocha -gc --reporter spec --use_strict" + "test": "mocha --reporter spec --use_strict" }, "dependencies": { "bindings": "1", @@ -35,11 +31,9 @@ "nan": "2" }, "devDependencies": { - "dox": "0.9.0", - "highlight.js": "1", - "jade": "1", - "marked": "0.5.2", - "mocha": "*", - "weak": "1" + "mocha": "6" + }, + "engines": { + "node": ">=8" } } diff --git a/src/binding.cc b/src/binding.cc index 7075be1..97f7300 100644 --- a/src/binding.cc +++ b/src/binding.cc @@ -2,9 +2,9 @@ #include #include -#include "node.h" -#include "node_buffer.h" -#include "nan.h" +#include +#include +#include #ifdef _WIN32 #define __alignof__ __alignof @@ -156,144 +156,6 @@ inline Local WrapNullPointer() { return WrapPointer((char*)NULL, 0); } -/* - * Retreives a JS Object instance that was previously stored in - * the given Buffer instance at the given offset. - * - * info[0] - Buffer - the "buf" Buffer instance to read from - * info[1] - Number - the offset from the "buf" buffer's address to read from - */ - -NAN_METHOD(ReadObject) { - - Local buf = info[0]; - if (!Buffer::HasInstance(buf)) { - return Nan::ThrowTypeError("readObject: Buffer instance expected"); - } - - int64_t offset = GetInt64(info[1]); - char *ptr = Buffer::Data(buf.As()) + offset; - - if (ptr == NULL) { - return Nan::ThrowError("readObject: Cannot read from NULL pointer"); - } - - Persistent* prtn = reinterpret_cast*>(ptr); - Local rtn = Nan::New(*prtn); - info.GetReturnValue().Set(rtn); -} - -/* - * Callback function for when the weak persistent object from WriteObject - * gets garbage collected. We just have to dispose of our weak reference now. - */ - -void write_object_cb(const Nan::WeakCallbackInfo& data) { - //fprintf(stderr, "write_object_cb\n"); - //NanDisposePersistent(data.GetValue()); -} - -/* - * Writes a Persistent reference to given Object to the given Buffer - * instance and offset. - * - * info[0] - Buffer - the "buf" Buffer instance to write to - * info[1] - Number - the offset from the "buf" buffer's address to write to - * info[2] - Object - the "obj" Object which will have a new Persistent reference - * created for the obj, who'se memory address will be written - * info[3] - Boolean - `false` by default. if `true` is passed in then a - * persistent reference will be written to the Buffer instance. - * A weak reference gets written by default. - */ - -NAN_METHOD(WriteObject) { - - Local buf = info[0]; - if (!Buffer::HasInstance(buf)) { - return Nan::ThrowTypeError("writeObject: Buffer instance expected"); - } - - int64_t offset = GetInt64(info[1]); - char *ptr = Buffer::Data(buf.As()) + offset; - - Nan::Persistent* pptr = reinterpret_cast*>(ptr); - Local val = info[2].As(); - - bool persistent = info[3]->BooleanValue(); - if (persistent) { - (*pptr).Reset(val); - } else { - void *user_data = NULL; - Nan::Persistent p2(val); - p2.SetWeak(user_data, write_object_cb, Nan::WeakCallbackType::kParameter); - memcpy(pptr, &p2, sizeof(Nan::Persistent)); - } - - info.GetReturnValue().SetUndefined(); -} - -/* - * Reads the memory address of the given "buf" pointer Buffer at the specified - * offset, and returns a new SlowBuffer instance from the memory address stored. - * - * info[0] - Buffer - the "buf" Buffer instance to read from - * info[1] - Number - the offset from the "buf" buffer's address to read from - * info[2] - Number - the length in bytes of the returned SlowBuffer instance - */ - -NAN_METHOD(ReadPointer) { - - Local buf = info[0]; - if (!Buffer::HasInstance(buf)) { - return Nan::ThrowTypeError("readPointer: Buffer instance expected as first argument"); - } - - int64_t offset = GetInt64(info[1]); - char *ptr = Buffer::Data(buf.As()) + offset; - size_t size = info[2]->Uint32Value(); - - if (ptr == NULL) { - return Nan::ThrowError("readPointer: Cannot read from NULL pointer"); - } - - char *val = *reinterpret_cast(ptr); - info.GetReturnValue().Set(WrapPointer(val, size)); -} - -/* - * Writes the memory address of the "input" buffer (and optional offset) to the - * specified "buf" buffer and offset. Essentially making "buf" hold a reference - * to the "input" Buffer. - * - * info[0] - Buffer - the "buf" Buffer instance to write to - * info[1] - Number - the offset from the "buf" buffer's address to write to - * info[2] - Buffer - the "input" Buffer whose memory address will be written - */ - -NAN_METHOD(WritePointer) { - - Local buf = info[0]; - Local input = info[2]; - if (!Buffer::HasInstance(buf)) { - return Nan::ThrowTypeError("writePointer: Buffer instance expected as first argument"); - } - if (!(input->IsNull() || Buffer::HasInstance(input))) { - return Nan::ThrowTypeError("writePointer: Buffer instance expected as third argument"); - } - - int64_t offset = GetInt64(info[1]); - char *ptr = Buffer::Data(buf.As()) + offset; - - if (input->IsNull()) { - *reinterpret_cast(ptr) = NULL; - } else { - char *input_ptr = Buffer::Data(input.As()); - *reinterpret_cast(ptr) = input_ptr; - } - - info.GetReturnValue().SetUndefined(); -} - /* * Reads a machine-endian int64_t from the given Buffer at the given offset. * @@ -357,7 +219,7 @@ NAN_METHOD(WriteInt64) { } else if (in->IsString()) { char *endptr, *str; int base = 0; - String::Utf8Value _str(in); + String::Utf8Value _str(v8::Isolate::GetCurrent(), in); str = *_str; errno = 0; /* To distinguish success/failure after call */ @@ -444,7 +306,7 @@ NAN_METHOD(WriteUInt64) { } else if (in->IsString()) { char *endptr, *str; int base = 0; - String::Utf8Value _str(in); + String::Utf8Value _str(v8::Isolate::GetCurrent(), in); str = *_str; errno = 0; /* To distinguish success/failure after call */ @@ -468,107 +330,6 @@ NAN_METHOD(WriteUInt64) { info.GetReturnValue().SetUndefined(); } -/* - * Reads a Utf8 C String from the given pointer at the given offset (or 0). - * I didn't want to add this function but it ends up being necessary for reading - * past a 0 or 1 length Buffer's boundary in node-ffi :\ - * - * info[0] - Buffer - the "buf" Buffer instance to read from - * info[1] - Number - the offset from the "buf" buffer's address to read from - */ - -NAN_METHOD(ReadCString) { - - Local buf = info[0]; - if (!Buffer::HasInstance(buf)) { - return Nan::ThrowTypeError("readCString: Buffer instance expected"); - } - - int64_t offset = GetInt64(info[1]); - char *ptr = Buffer::Data(buf.As()) + offset; - - if (ptr == NULL) { - return Nan::ThrowError("readCString: Cannot read from NULL pointer"); - } - - Local rtn = Nan::New(ptr).ToLocalChecked(); - info.GetReturnValue().Set(rtn); -} - -/* - * Returns a new Buffer instance that has the same memory address - * as the given buffer, but with the specified size. - * - * info[0] - Buffer - the "buf" Buffer instance to read the address from - * info[1] - Number - the size in bytes that the returned Buffer should be - * info[2] - Number - the offset from the "buf" buffer's address to read from - */ - -NAN_METHOD(ReinterpretBuffer) { - - Local buf = info[0]; - if (!Buffer::HasInstance(buf)) { - return Nan::ThrowTypeError("reinterpret: Buffer instance expected"); - } - - int64_t offset = GetInt64(info[2]); - char *ptr = Buffer::Data(buf.As()) + offset; - - if (ptr == NULL) { - return Nan::ThrowError("reinterpret: Cannot reinterpret from NULL pointer"); - } - - size_t size = info[1]->Uint32Value(); - - info.GetReturnValue().Set(WrapPointer(ptr, size)); -} - -/* - * Returns a new Buffer instance that has the same memory address - * as the given buffer, but with a length up to the first aligned set of values of - * 0 in a row for the given length. - * - * info[0] - Buffer - the "buf" Buffer instance to read the address from - * info[1] - Number - the number of sequential 0-byte values that need to be read - * info[2] - Number - the offset from the "buf" buffer's address to read from - */ - -NAN_METHOD(ReinterpretBufferUntilZeros) { - - Local buf = info[0]; - if (!Buffer::HasInstance(buf)) { - return Nan::ThrowTypeError("reinterpretUntilZeros: Buffer instance expected"); - } - - int64_t offset = GetInt64(info[2]); - char *ptr = Buffer::Data(buf.As()) + offset; - - if (ptr == NULL) { - return Nan::ThrowError("reinterpretUntilZeros: Cannot reinterpret from NULL pointer"); - } - - uint32_t numZeros = info[1]->Uint32Value(); - uint32_t i = 0; - size_t size = 0; - bool end = false; - - while (!end && size < kMaxLength) { - end = true; - for (i = 0; i < numZeros; i++) { - if (ptr[size + i] != 0) { - end = false; - break; - } - } - if (!end) { - size += numZeros; - } - } - - info.GetReturnValue().Set(WrapPointer(ptr, size)); -} - - } // anonymous namespace NAN_MODULE_INIT(init) { @@ -578,7 +339,7 @@ NAN_MODULE_INIT(init) { Local smap = Nan::New(); // fixed sizes #define SET_SIZEOF(name, type) \ - smap->Set(Nan::New( #name ).ToLocalChecked(), Nan::New(static_cast(sizeof(type)))); + Nan::Set(smap, Nan::New( #name ).ToLocalChecked(), Nan::New(static_cast(sizeof(type)))); SET_SIZEOF(int8, int8_t); SET_SIZEOF(uint8, uint8_t); SET_SIZEOF(int16, int16_t); @@ -605,14 +366,12 @@ NAN_MODULE_INIT(init) { SET_SIZEOF(pointer, char *); SET_SIZEOF(size_t, size_t); SET_SIZEOF(wchar_t, wchar_t); - // size of a Persistent handle to a JS object - SET_SIZEOF(Object, Nan::Persistent); // "alignof" map Local amap = Nan::New(); #define SET_ALIGNOF(name, type) \ struct s_##name { type a; }; \ - amap->Set(Nan::New( #name ).ToLocalChecked(), Nan::New(static_cast(__alignof__(struct s_##name)))); + Nan::Set(amap, Nan::New( #name ).ToLocalChecked(), Nan::New(static_cast(__alignof__(struct s_##name)))); SET_ALIGNOF(int8, int8_t); SET_ALIGNOF(uint8, uint8_t); SET_ALIGNOF(int16, int16_t); @@ -637,26 +396,18 @@ NAN_MODULE_INIT(init) { SET_ALIGNOF(pointer, char *); SET_ALIGNOF(size_t, size_t); SET_ALIGNOF(wchar_t, wchar_t); - SET_ALIGNOF(Object, Nan::Persistent); // exports - target->Set(Nan::New("sizeof").ToLocalChecked(), smap); - target->Set(Nan::New("alignof").ToLocalChecked(), amap); - Nan::ForceSet(target, Nan::New("endianness").ToLocalChecked(), Nan::New(CheckEndianness()).ToLocalChecked(), static_cast(ReadOnly|DontDelete)); - Nan::ForceSet(target, Nan::New("NULL").ToLocalChecked(), WrapNullPointer(), static_cast(ReadOnly|DontDelete)); + Nan::Set(target, Nan::New("sizeof").ToLocalChecked(), smap); + Nan::Set(target, Nan::New("alignof").ToLocalChecked(), amap); + Nan::DefineOwnProperty(target, Nan::New("endianness").ToLocalChecked(), Nan::New(CheckEndianness()).ToLocalChecked(), static_cast(ReadOnly|DontDelete)); + Nan::DefineOwnProperty(target, Nan::New("NULL").ToLocalChecked(), WrapNullPointer(), static_cast(ReadOnly|DontDelete)); Nan::SetMethod(target, "address", Address); Nan::SetMethod(target, "hexAddress", HexAddress); Nan::SetMethod(target, "isNull", IsNull); - Nan::SetMethod(target, "readObject", ReadObject); - Nan::SetMethod(target, "writeObject", WriteObject); - Nan::SetMethod(target, "readPointer", ReadPointer); - Nan::SetMethod(target, "writePointer", WritePointer); Nan::SetMethod(target, "readInt64", ReadInt64); Nan::SetMethod(target, "writeInt64", WriteInt64); Nan::SetMethod(target, "readUInt64", ReadUInt64); Nan::SetMethod(target, "writeUInt64", WriteUInt64); - Nan::SetMethod(target, "readCString", ReadCString); - Nan::SetMethod(target, "reinterpret", ReinterpretBuffer); - Nan::SetMethod(target, "reinterpretUntilZeros", ReinterpretBufferUntilZeros); } NODE_MODULE(binding, init); diff --git a/test/address.js b/test/address.js index eb89ce7..5c934dc 100644 --- a/test/address.js +++ b/test/address.js @@ -4,7 +4,7 @@ var inspect = require('util').inspect describe('address', function () { - var buf = new Buffer('hello') + var buf = Buffer.from('hello') it('should return 0 for the NULL pointer', function () { assert.strictEqual(0, ref.address(ref.NULL)) diff --git a/test/alloc.js b/test/alloc.js deleted file mode 100644 index ea693c8..0000000 --- a/test/alloc.js +++ /dev/null @@ -1,17 +0,0 @@ - -var assert = require('assert') -var ref = require('../') - -describe('alloc()', function () { - - it('should return a new Buffer of "bool" size', function () { - var buf = ref.alloc(ref.types.bool) - assert.equal(ref.sizeof.bool, buf.length) - }) - - it('should coerce string type names', function () { - var buf = ref.alloc('bool') - assert.strictEqual(ref.types.bool, buf.type) - }) - -}) diff --git a/test/bool.js b/test/bool.js deleted file mode 100644 index 3186916..0000000 --- a/test/bool.js +++ /dev/null @@ -1,36 +0,0 @@ - -var assert = require('assert') -var ref = require('../') - -describe('bool', function () { - - var buf = ref.alloc('bool') - - it('should return JS "false" for a value of 0', function () { - buf[0] = 0 - assert.strictEqual(false, ref.get(buf)) - }) - - it('should return JS "true" for a value of 1', function () { - buf[0] = 1 - assert.strictEqual(true, ref.get(buf)) - }) - - it('should write a JS "false" value as 0', function () { - ref.set(buf, 0, false) - assert.strictEqual(0, buf[0]) - }) - - it('should write a JS "true" value as 1', function () { - ref.set(buf, 0, true) - assert.strictEqual(1, buf[0]) - }) - - it('should allow uint8 number values to be written to it', function () { - var val = 255 - ref.set(buf, 0, val) - assert.strictEqual(true, ref.get(buf)) - assert.strictEqual(val, buf[0]) - }) - -}) diff --git a/test/char.js b/test/char.js deleted file mode 100644 index 80a1071..0000000 --- a/test/char.js +++ /dev/null @@ -1,17 +0,0 @@ - -var assert = require('assert') -var ref = require('../') - -describe('char', function () { - - it('should accept a JS String, and write the first char\'s code', function () { - var val = 'a' - - var buf = ref.alloc('char', val) - assert.strictEqual(val.charCodeAt(0), buf.deref()) - - buf = ref.alloc('uchar', val) - assert.strictEqual(val.charCodeAt(0), buf.deref()) - }) - -}) diff --git a/test/coerce.js b/test/coerce.js deleted file mode 100644 index a77e111..0000000 --- a/test/coerce.js +++ /dev/null @@ -1,48 +0,0 @@ - -var assert = require('assert') -var ref = require('../') - -describe('coerce', function () { - - it('should return `ref.types.void` for "void"', function () { - var type = ref.coerceType('void') - assert.strictEqual(ref.types.void, type) - }) - - it('should return a ref type when a "*" is present', function () { - var type = ref.coerceType('void *') - assert(type !== ref.types.void) - assert.equal(type.indirection, ref.types.void.indirection + 1) - }) - - it('should coerce the "type" property of a Buffer', function () { - var buf = new Buffer(ref.sizeof.int) - buf.type = 'int' - var type = ref.getType(buf) - assert.strictEqual(ref.types.int, type) - assert.strictEqual('int', buf.type) - }) - - it('should coerce "Object" to `ref.types.Object`', function () { - assert.strictEqual(ref.types.Object, ref.coerceType('Object')) - }) - - it('should coerce the optional type in `ref.get()`', function () { - var b = new Buffer(ref.sizeof.int8) - b[0] = 5 - assert.strictEqual(5, ref.get(b, 0, 'int8')) - }) - - it('should coerce the optional type in `ref.set()`', function () { - var b = new Buffer(ref.sizeof.int8) - ref.set(b, 0, 5, 'int8') - assert.strictEqual(5, b[0]) - }) - - it('should throw a TypeError if a "type" can not be inferred', function () { - assert.throws(function () { - ref.coerceType({ }) - }, /could not determine a proper \"type\"/) - }) - -}) diff --git a/test/int64.js b/test/int64.js index 860ed33..072d0e9 100644 --- a/test/int64.js +++ b/test/int64.js @@ -7,7 +7,7 @@ describe('int64', function () { var JS_MIN_INT = -9007199254740992 it('should allow simple ints to be written and read', function () { - var buf = new Buffer(ref.sizeof.int64) + var buf = Buffer.alloc(ref.sizeof.int64) var val = 123456789 ref.writeInt64(buf, 0, val) var rtn = ref.readInt64(buf, 0) @@ -15,7 +15,7 @@ describe('int64', function () { }) it('should allow INT64_MAX to be written and read', function () { - var buf = new Buffer(ref.sizeof.int64) + var buf = Buffer.alloc(ref.sizeof.int64) var val = '9223372036854775807' ref.writeInt64(buf, 0, val) var rtn = ref.readInt64(buf, 0) @@ -23,7 +23,7 @@ describe('int64', function () { }) it('should allow a hex String to be input (signed)', function () { - var buf = new Buffer(ref.sizeof.int64) + var buf = Buffer.alloc(ref.sizeof.int64) var val = '-0x1234567890' ref.writeInt64(buf, 0, val) var rtn = ref.readInt64(buf, 0) @@ -31,7 +31,7 @@ describe('int64', function () { }) it('should allow an octal String to be input (signed)', function () { - var buf = new Buffer(ref.sizeof.int64) + var buf = Buffer.alloc(ref.sizeof.int64) var val = '-0777' ref.writeInt64(buf, 0, val) var rtn = ref.readInt64(buf, 0) @@ -39,7 +39,7 @@ describe('int64', function () { }) it('should allow a hex String to be input (unsigned)', function () { - var buf = new Buffer(ref.sizeof.uint64) + var buf = Buffer.alloc(ref.sizeof.uint64) var val = '0x1234567890' ref.writeUInt64(buf, 0, val) var rtn = ref.readUInt64(buf, 0) @@ -47,7 +47,7 @@ describe('int64', function () { }) it('should allow an octal String to be input (unsigned)', function () { - var buf = new Buffer(ref.sizeof.uint64) + var buf = Buffer.alloc(ref.sizeof.uint64) var val = '0777' ref.writeUInt64(buf, 0, val) var rtn = ref.readUInt64(buf, 0) @@ -55,7 +55,7 @@ describe('int64', function () { }) it('should return a Number when reading JS_MIN_INT', function () { - var buf = new Buffer(ref.sizeof.int64) + var buf = Buffer.alloc(ref.sizeof.int64) ref.writeInt64(buf, 0, JS_MIN_INT) var rtn = ref.readInt64(buf, 0) assert.equal('number', typeof rtn) @@ -63,7 +63,7 @@ describe('int64', function () { }) it('should return a Number when reading JS_MAX_INT', function () { - var buf = new Buffer(ref.sizeof.int64) + var buf = Buffer.alloc(ref.sizeof.int64) ref.writeInt64(buf, 0, JS_MAX_INT) var rtn = ref.readInt64(buf, 0) assert.equal('number', typeof rtn) @@ -71,7 +71,7 @@ describe('int64', function () { }) it('should return a String when reading JS_MAX_INT+1', function () { - var buf = new Buffer(ref.sizeof.int64) + var buf = Buffer.alloc(ref.sizeof.int64) var plus_one = '9007199254740993' ref.writeInt64(buf, 0, plus_one) var rtn = ref.readInt64(buf, 0) @@ -80,7 +80,7 @@ describe('int64', function () { }) it('should return a String when reading JS_MIN_INT-1', function () { - var buf = new Buffer(ref.sizeof.int64) + var buf = Buffer.alloc(ref.sizeof.int64) var minus_one = '-9007199254740993' ref.writeInt64(buf, 0, minus_one) var rtn = ref.readInt64(buf, 0) @@ -89,7 +89,7 @@ describe('int64', function () { }) it('should return a Number when reading 0, even when written as a String', function () { - var buf = new Buffer(ref.sizeof.int64) + var buf = Buffer.alloc(ref.sizeof.int64) var zero = '0' ref.writeInt64(buf, 0, zero) var rtn = ref.readInt64(buf, 0) @@ -99,14 +99,14 @@ describe('int64', function () { it('should throw a "no digits" Error when writing an invalid String (signed)', function () { assert.throws(function () { - var buf = new Buffer(ref.sizeof.int64) + var buf = Buffer.alloc(ref.sizeof.int64) ref.writeInt64(buf, 0, 'foo') }, /no digits we found in input String/) }) it('should throw a "no digits" Error when writing an invalid String (unsigned)', function () { assert.throws(function () { - var buf = new Buffer(ref.sizeof.uint64) + var buf = Buffer.alloc(ref.sizeof.uint64) ref.writeUInt64(buf, 0, 'foo') }, /no digits we found in input String/) }) @@ -114,7 +114,7 @@ describe('int64', function () { it('should throw an "out of range" Error when writing an invalid String (signed)', function () { var e; try { - var buf = new Buffer(ref.sizeof.int64) + var buf = Buffer.alloc(ref.sizeof.int64) ref.writeInt64(buf, 0, '10000000000000000000000000') } catch (_e) { e = _e; @@ -125,7 +125,7 @@ describe('int64', function () { it('should throw an "out of range" Error when writing an invalid String (unsigned)', function () { var e; try { - var buf = new Buffer(ref.sizeof.uint64) + var buf = Buffer.alloc(ref.sizeof.uint64) ref.writeUInt64(buf, 0, '10000000000000000000000000') } catch (_e) { e = _e; @@ -145,26 +145,26 @@ describe('int64', function () { }) }) - ;['LE', 'BE'].forEach(function (endianness) { + ;['LE', 'BE'].forEach(function (endianness) { - describe(endianness, function () { + describe(endianness, function () { - it('should read and write a signed ' + endianness + ' 64-bit integer', function () { - var val = -123456789 - var buf = new Buffer(ref.sizeof.int64) - ref['writeInt64' + endianness](buf, 0, val) - assert.equal(val, ref['readInt64' + endianness](buf, 0)) - }) + it('should read and write a signed ' + endianness + ' 64-bit integer', function () { + var val = -123456789 + var buf = Buffer.alloc(ref.sizeof.int64) + ref['writeInt64' + endianness](buf, 0, val) + assert.equal(val, ref['readInt64' + endianness](buf, 0)) + }) + + it('should read and write an unsigned ' + endianness + ' 64-bit integer', function () { + var val = 123456789 + var buf = Buffer.alloc(ref.sizeof.uint64) + ref['writeUInt64' + endianness](buf, 0, val) + assert.equal(val, ref['readUInt64' + endianness](buf, 0)) + }) - it('should read and write an unsigned ' + endianness + ' 64-bit integer', function () { - var val = 123456789 - var buf = new Buffer(ref.sizeof.uint64) - ref['writeUInt64' + endianness](buf, 0, val) - assert.equal(val, ref['readUInt64' + endianness](buf, 0)) }) }) - }) - }) diff --git a/test/iojs3issue.js b/test/iojs3issue.js deleted file mode 100644 index cdb1f60..0000000 --- a/test/iojs3issue.js +++ /dev/null @@ -1,24 +0,0 @@ -var assert = require('assert') -var ref = require('../') - -// This will check if the new Buffer implementation behaves like the pre io.js 3.0 one did: -describe('iojs3issue', function () { - it('should not crash', function() { - for (var i = 0; i < 10; i++) { - gc() - var buf = new Buffer(8) - buf.fill(0) - var buf2 = ref.ref(buf) - var buf3 = ref.deref(buf2) - } - }) - it('should not crash too', function() { - for (var i = 0; i < 10; i++) { - gc() - var buf = new Buffer(7) - buf.fill(0) - var buf2 = ref.ref(buf) - var buf3 = ref.deref(buf2) - } - }) -}) \ No newline at end of file diff --git a/test/isNull.js b/test/isNull.js index 0677301..b9f4fee 100644 --- a/test/isNull.js +++ b/test/isNull.js @@ -9,7 +9,7 @@ describe('isNull', function () { }) it('should return "false" for a valid Buffer', function () { - var buf = new Buffer('hello') + var buf = Buffer.from('hello') assert.strictEqual(false, ref.isNull(buf)) }) diff --git a/test/object.js b/test/object.js deleted file mode 100644 index 85ac64d..0000000 --- a/test/object.js +++ /dev/null @@ -1,74 +0,0 @@ - -var assert = require('assert') -var weak = require('weak') -var ref = require('../') - -describe('Object', function () { - - var obj = { - foo: 'bar' - , test: Math.random() - , now: new Date() - } - - beforeEach(gc) - - it('should write and read back an Object in a Buffer', function () { - var buf = new Buffer(ref.sizeof.Object) - ref.writeObject(buf, 0, obj) - var out = ref.readObject(buf) - assert.strictEqual(obj, out) - assert.deepEqual(obj, out) - }) - - it('should retain references to written Objects', function (done) { - var o_gc = false - var buf_gc = false - var o = { foo: 'bar' } - var buf = new Buffer(ref.sizeof.Object) - - weak(o, function () { o_gc = true }) - weak(buf, function () { buf_gc = true }) - ref.writeObject(buf, 0, o) - assert(!o_gc, '"o" has been garbage collected too soon') - assert(!buf_gc, '"buf" has been garbage collected too soon') - - // try to GC `o` - o = null - gc() - assert(!o_gc, '"o" has been garbage collected too soon') - assert(!buf_gc, '"buf" has been garbage collected too soon') - - // now GC `buf` - buf = null - setImmediate(function () { - gc() - assert(buf_gc, '"buf" has not been garbage collected') - assert(o_gc, '"o" has not been garbage collected') - done() - }); - }) - - it('should throw an Error when reading an Object from the NULL pointer', function () { - assert.throws(function () { - ref.NULL.readObject() - }) - }) - - describe('offset', function () { - - it('should read two Objects next to each other in memory', function () { - var buf = new Buffer(ref.sizeof.pointer * 2) - var a = {} - var b = {} - buf.writeObject(a, 0 * ref.sizeof.pointer) - buf.writeObject(b, 1 * ref.sizeof.pointer) - var _a = buf.readObject(0 * ref.sizeof.pointer) - var _b = buf.readObject(1 * ref.sizeof.pointer) - assert.strictEqual(a, _a) - assert.strictEqual(b, _b) - }) - - }) - -}) diff --git a/test/pointer.js b/test/pointer.js deleted file mode 100644 index 3aa1300..0000000 --- a/test/pointer.js +++ /dev/null @@ -1,80 +0,0 @@ - -var assert = require('assert') -var weak = require('weak') -var ref = require('../') - -describe('pointer', function () { - - var test = new Buffer('hello world') - - beforeEach(gc) - - it('should write and read back a pointer (Buffer) in a Buffer', function () { - var buf = new Buffer(ref.sizeof.pointer) - ref.writePointer(buf, 0, test) - var out = ref.readPointer(buf, 0, test.length) - assert.strictEqual(out.length, test.length) - for (var i = 0, l = out.length; i < l; i++) { - assert.strictEqual(out[i], test[i]) - } - assert.strictEqual(ref.address(out), ref.address(test)) - }) - - it('should retain references to a written pointer in a Buffer', function (done) { - var child_gc = false - var parent_gc = false - var child = new Buffer('a pointer holding some data...') - var parent = new Buffer(ref.sizeof.pointer) - - weak(child, function () { child_gc = true }) - weak(parent, function () { parent_gc = true }) - ref.writePointer(parent, 0, child) - assert(!child_gc, '"child" has been garbage collected too soon') - assert(!parent_gc, '"parent" has been garbage collected too soon') - - // try to GC `child` - child = null - gc() - assert(!child_gc, '"child" has been garbage collected too soon') - assert(!parent_gc, '"parent" has been garbage collected too soon') - - // now GC `parent` - parent = null - setImmediate(function () { - gc() - assert(parent_gc, '"parent" has not been garbage collected') - assert(child_gc, '"child" has not been garbage collected') - done() - }); - }) - - it('should throw an Error when reading from the NULL pointer', function () { - assert.throws(function () { - ref.NULL.readPointer() - }) - }) - - it('should return a 0-length Buffer when reading a NULL pointer', function () { - var buf = new Buffer(ref.sizeof.pointer) - ref.writePointer(buf, 0, ref.NULL) - var out = ref.readPointer(buf, 0, 100) - assert.strictEqual(out.length, 0) - }) - - describe('offset', function () { - - it('should read two pointers next to each other in memory', function () { - var buf = new Buffer(ref.sizeof.pointer * 2) - var a = new Buffer('hello') - var b = new Buffer('world') - buf.writePointer(a, 0 * ref.sizeof.pointer) - buf.writePointer(b, 1 * ref.sizeof.pointer) - var _a = buf.readPointer(0 * ref.sizeof.pointer) - var _b = buf.readPointer(1 * ref.sizeof.pointer) - assert.equal(a.address(), _a.address()) - assert.equal(b.address(), _b.address()) - }) - - }) - -}) diff --git a/test/ref-deref.js b/test/ref-deref.js deleted file mode 100644 index d805919..0000000 --- a/test/ref-deref.js +++ /dev/null @@ -1,61 +0,0 @@ - -var assert = require('assert') -var ref = require('../') - -describe('ref(), deref()', function () { - - beforeEach(gc) - - it('should work 1 layer deep', function () { - var test = new Buffer('one layer deep') - var one = ref.ref(test) - var _test = ref.deref(one) - assert.equal(test.length, _test.length) - assert.equal(test.toString(), _test.toString()) - }) - - it('should work 2 layers deep', function () { - var test = new Buffer('two layers deep') - var one = ref.ref(test) - var two = ref.ref(one) - var _one = ref.deref(two) - var _test = ref.deref(_one) - assert.equal(ref.address(one), ref.address(_one)) - assert.equal(ref.address(test), ref.address(_test)) - assert.equal(one.length, _one.length) - assert.equal(test.length, _test.length) - assert.equal(test.toString(), _test.toString()) - }) - - it('should throw when derefing a Buffer with no "type"', function () { - var test = new Buffer('???') - assert.throws(function () { - ref.deref(test) - }, /unknown "type"/) - }) - - it('should throw when derefing a Buffer with no "type" 2', function () { - var test = new Buffer('???') - var r = ref.ref(test) - var _test = ref.deref(r) - assert.equal(ref.address(test), ref.address(_test)) - assert.throws(function () { - ref.deref(_test) - }, /unknown "type"/) - }) - - it('should deref() a "char" type properly', function () { - var test = new Buffer(ref.sizeof.char) - test.type = ref.types.char - test[0] = 50 - assert.equal(50, ref.deref(test)) - test[0] = 127 - assert.equal(127, ref.deref(test)) - }) - - it('should not throw when calling ref()/deref() on a `void` type', function () { - var test = ref.alloc(ref.types.void) - assert.strictEqual(null, test.deref()) - }) - -}) diff --git a/test/reinterpret.js b/test/reinterpret.js deleted file mode 100644 index 230d778..0000000 --- a/test/reinterpret.js +++ /dev/null @@ -1,57 +0,0 @@ - -var assert = require('assert') -var weak = require('weak') -var ref = require('../') - -describe('reinterpret()', function () { - - beforeEach(gc) - - it('should return a new Buffer instance at the same address', function () { - var buf = new Buffer('hello world') - var small = buf.slice(0, 0) - assert.strictEqual(0, small.length) - assert.strictEqual(buf.address(), small.address()) - var reinterpreted = small.reinterpret(buf.length) - assert.strictEqual(buf.address(), reinterpreted.address()) - assert.strictEqual(buf.length, reinterpreted.length) - assert.strictEqual(buf.toString(), reinterpreted.toString()) - }) - - it('should return a new Buffer instance starting at the offset address', function () { - var buf = new Buffer('hello world') - var offset = 3 - var small = buf.slice(offset, buf.length) - assert.strictEqual(buf.length - offset, small.length) - assert.strictEqual(buf.address() + offset, small.address()) - var reinterpreted = buf.reinterpret(small.length, offset) - assert.strictEqual(small.address(), reinterpreted.address()) - assert.strictEqual(small.length, reinterpreted.length) - assert.strictEqual(small.toString(), reinterpreted.toString()) - }) - - it('should retain a reference to the original Buffer when reinterpreted', function () { - var origGCd = false - var otherGCd = false - var buf = new Buffer(1) - weak(buf, function () { origGCd = true }) - var other = buf.reinterpret(0) - weak(other, function () { otherGCd = true }) - - assert(!origGCd, '"buf" has been garbage collected too soon') - assert(!otherGCd, '"other" has been garbage collected too soon') - - // try to GC `buf` - buf = null - gc() - assert(!origGCd, '"buf" has been garbage collected too soon') - assert(!otherGCd, '"other" has been garbage collected too soon') - - // now GC `other` - other = null - gc() - assert(otherGCd, '"other" has not been garbage collected') - assert(origGCd, '"buf" has not been garbage collected') - }) - -}) diff --git a/test/reinterpretUntilZeros.js b/test/reinterpretUntilZeros.js deleted file mode 100644 index 9210f70..0000000 --- a/test/reinterpretUntilZeros.js +++ /dev/null @@ -1,45 +0,0 @@ - -var fs = require('fs') -var assert = require('assert') -var weak = require('weak') -var ref = require('../') - -describe('reinterpretUntilZeros()', function () { - - beforeEach(gc) - - it('should return a new Buffer instance up until the first 0', function () { - var buf = new Buffer('hello\0world') - var buf2 = buf.reinterpretUntilZeros(1) - assert.equal(buf2.length, 'hello'.length) - assert.equal(buf2.toString(), 'hello') - }) - - it('should return a new Buffer instance up until the first 0 starting from offset', function () { - var buf = new Buffer('hello\0world') - var buf2 = buf.reinterpretUntilZeros(1, 3) - assert.equal(buf2.length, 'lo'.length) - assert.equal(buf2.toString(), 'lo') - }) - - it('should return a new Buffer instance up until the first 2-byte sequence of 0s', function () { - var str = 'hello world' - var buf = new Buffer(50) - var len = buf.write(str, 'ucs2') - buf.writeInt16LE(0, len) // NULL terminate the string - - var buf2 = buf.reinterpretUntilZeros(2) - assert.equal(str.length, buf2.length / 2) - assert.equal(buf2.toString('ucs2'), str) - }) - - it('should return a large Buffer instance > 10,000 bytes with UTF16-LE char bytes', function () { - var data = fs.readFileSync(__dirname + '/utf16le.bin'); - var strBuf = ref.reinterpretUntilZeros(data, 2); - assert(strBuf.length > 10000); - var str = strBuf.toString('ucs2'); - // the data in `utf16le.bin` should be a JSON parsable string - assert(JSON.parse(str)); - }) - -}) diff --git a/test/string.js b/test/string.js deleted file mode 100644 index c9d3c74..0000000 --- a/test/string.js +++ /dev/null @@ -1,98 +0,0 @@ - -var assert = require('assert') -var ref = require('../') - -describe('C string', function () { - - describe('readCString()', function () { - - it('should return "" for a Buffer containing "\\0"', function () { - var buf = new Buffer('\0') - assert.strictEqual('', buf.readCString(0)) - }) - - it('should return "hello" for a Buffer containing "hello\\0world"', function () { - var buf = new Buffer('hello\0world') - assert.strictEqual('hello', buf.readCString(0)) - }) - - it('should throw an Error when reading from the NULL pointer', function () { - assert.throws(function () { - ref.NULL.readCString() - }) - }) - - }) - - describe('writeCString()', function () { - - it('should write a C string (NULL terminated) to a Buffer', function () { - var buf = new Buffer(20) - var str = 'hello world' - buf.writeCString(str) - for (var i = 0; i < str.length; i++) { - assert.equal(str.charCodeAt(i), buf[i]) - } - assert.equal(0, buf[str.length]) - }) - - }) - - describe('allocCString()', function () { - - it('should return a new Buffer containing the given string', function () { - var buf = ref.allocCString('hello world') - assert.strictEqual('hello world', buf.readCString()) - }) - - it('should return the NULL pointer for `null` values', function () { - var buf = ref.allocCString(null) - assert(buf.isNull()) - assert.strictEqual(0, buf.address()) - }) - - it('should return the NULL pointer for `undefined` values', function () { - var buf = ref.allocCString(undefined) - assert(buf.isNull()) - assert.strictEqual(0, buf.address()) - }) - - it('should return the NULL pointer for a NULL pointer Buffer', function () { - var buf = ref.allocCString(ref.NULL) - assert(buf.isNull()) - assert.strictEqual(0, buf.address()) - }) - - }) - - describe('CString', function () { - - it('should return JS `null` when given a pointer pointing to NULL', function () { - var buf = ref.alloc(ref.types.CString) - buf.writePointer(ref.NULL) - assert.strictEqual(null, buf.deref()) - - // another version of the same test - assert.strictEqual(null, ref.get(ref.NULL_POINTER, 0, ref.types.CString)) - }) - - it('should read a utf8 string from a Buffer', function () { - var str = 'hello world' - var buf = ref.alloc(ref.types.CString) - buf.writePointer(new Buffer(str + '\0')) - assert.strictEqual(str, buf.deref()) - }) - - // https://github.com/node-ffi/node-ffi/issues/169 - it('should set a Buffer as backing store', function () { - var str = 'hey!' - var store = new Buffer(str + '\0') - var buf = ref.alloc(ref.types.CString) - ref.set(buf, 0, store) - - assert.equal(str, ref.get(buf, 0)) - }) - - }) - -}) diff --git a/test/types.js b/test/types.js index 8b06d0d..ec99751 100644 --- a/test/types.js +++ b/test/types.js @@ -4,63 +4,6 @@ var ref = require('../') describe('types', function () { - describe('refType()', function () { - - it('should return a new "type" with its `indirection` level increased by 1', function () { - var int = ref.types.int - var intPtr = ref.refType(int) - assert.equal(int.size, intPtr.size) - assert.equal(int.indirection + 1, intPtr.indirection) - }) - - it('should coerce string types', function () { - var intPtr = ref.refType('int') - assert.equal(2, intPtr.indirection) - assert.equal(intPtr.size, ref.types.int.size) - }) - - it('should override and update a read-only name property', function () { - // a type similar to ref-struct's StructType - // used for types refType name property test - function StructType() {} - StructType.size = 0 - StructType.indirection = 0 - - // read-only name property - assert.equal(StructType.name, 'StructType') - try { - StructType.name = 'foo' - } catch (err) { - // ignore - } - assert.equal(StructType.name, 'StructType') - - // name property should be writable and updated - var newObj = ref.refType(StructType) - var newProp = Object.getOwnPropertyDescriptor(newObj, 'name') - assert.equal(newProp.writable, true) - assert.equal(newObj.name, 'StructType*') - }) - }) - - describe('derefType()', function () { - - it('should return a new "type" with its `indirection` level decreased by 1', function () { - var intPtr = Object.create(ref.types.int) - intPtr.indirection++ - var int = ref.derefType(intPtr) - assert.equal(intPtr.size, intPtr.size) - assert.equal(intPtr.indirection - 1, int.indirection) - }) - - it('should throw an Error when given a "type" with its `indirection` level already at 1', function () { - assert.throws(function () { - ref.derefType(ref.types.int) - }) - }) - - }) - describe('size', function () { Object.keys(ref.types).forEach(function (name) { if (name === 'void') return