code stringlengths 24 2.07M | docstring stringlengths 25 85.3k | func_name stringlengths 1 92 | language stringclasses 1
value | repo stringlengths 5 64 | path stringlengths 4 172 | url stringlengths 44 218 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
function fixCloneNodeIssues( src, dest ) {
var nodeName, e, data;
// We do not need to do anything for non-Elements
if ( dest.nodeType !== 1 ) {
return;
}
nodeName = dest.nodeName.toLowerCase();
// IE6-8 copies events bound via attachEvent when using cloneNode.
if ( !support.noCloneEvent && dest[ jQuery.exp... | Determines whether an object can have data | fixCloneNodeIssues | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function actualDisplay( name, doc ) {
var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
// getDefaultComputedStyle might be reliably used only on attached element
display = window.getDefaultComputedStyle ?
// Use of this method is a temporary fix (more like optmization) until something bett... | Retrieve the actual display of a element
@param {String} name nodeName of the element
@param {Object} doc Document object | actualDisplay | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function defaultDisplay( nodeName ) {
var doc = document,
display = elemdisplay[ nodeName ];
if ( !display ) {
display = actualDisplay( nodeName, doc );
// If the simple way fails, read from inside an iframe
if ( display === "none" || !display ) {
// Use the already-created iframe if possible
iframe ... | Try to determine the default display value of an element
@param {String} nodeName | defaultDisplay | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function addGetHookIf( conditionFn, hookFn ) {
// Define the hook, we'll check on the first run if it's really needed.
return {
get: function() {
var condition = conditionFn();
if ( condition == null ) {
// The test was not ready at this point; screw the hook this time
// but check again when needed ... | Try to determine the default display value of an element
@param {String} nodeName | addGetHookIf | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function computeStyleTests() {
var container, div,
body = document.getElementsByTagName( "body" )[ 0 ];
if ( !body ) {
// Test fired too early or in an unsupported environment, exit.
return;
}
container = document.createElement( "div" );
div = document.createElement( "div" );
container.style.cssT... | Try to determine the default display value of an element
@param {String} nodeName | computeStyleTests | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function vendorPropName( style, name ) {
// shortcut for names that are not vendor prefixed
if ( name in style ) {
return name;
}
// check for vendor prefixed names
var capName = name.charAt(0).toUpperCase() + name.slice(1),
origName = name,
i = cssPrefixes.length;
while ( i-- ) {
name = cssPrefixes[ i... | Try to determine the default display value of an element
@param {String} nodeName | vendorPropName | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function showHide( elements, show ) {
var display, elem, hidden,
values = [],
index = 0,
length = elements.length;
for ( ; index < length; index++ ) {
elem = elements[ index ];
if ( !elem.style ) {
continue;
}
values[ index ] = jQuery._data( elem, "olddisplay" );
display = elem.style.display;
i... | Try to determine the default display value of an element
@param {String} nodeName | showHide | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function setPositiveNumber( elem, value, subtract ) {
var matches = rnumsplit.exec( value );
return matches ?
// Guard against undefined "subtract", e.g., when used as in cssHooks
Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
value;
} | Try to determine the default display value of an element
@param {String} nodeName | setPositiveNumber | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
var i = extra === ( isBorderBox ? "border" : "content" ) ?
// If we already have the right measurement, avoid augmentation
4 :
// Otherwise initialize for horizontal or vertical properties
name === "width" ? 1 : 0,
val = 0;
for ( ; ... | Try to determine the default display value of an element
@param {String} nodeName | augmentWidthOrHeight | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function getWidthOrHeight( elem, name, extra ) {
// Start with offset property, which is equivalent to the border-box value
var valueIsBorderBox = true,
val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
styles = getStyles( elem ),
isBorderBox = support.boxSizing() && jQuery.css( elem, "boxSizing",... | Try to determine the default display value of an element
@param {String} nodeName | getWidthOrHeight | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function Tween( elem, options, prop, end, easing ) {
return new Tween.prototype.init( elem, options, prop, end, easing );
} | Try to determine the default display value of an element
@param {String} nodeName | Tween | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function createFxNow() {
setTimeout(function() {
fxNow = undefined;
});
return ( fxNow = jQuery.now() );
} | Try to determine the default display value of an element
@param {String} nodeName | createFxNow | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function genFx( type, includeWidth ) {
var which,
attrs = { height: type },
i = 0;
// if we include width, step value is 1 to do all cssExpand values,
// if we don't include width, step value is 2 to skip over Left and Right
includeWidth = includeWidth ? 1 : 0;
for ( ; i < 4 ; i += 2 - includeWidth ) {
whic... | Try to determine the default display value of an element
@param {String} nodeName | genFx | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function createTween( value, prop, animation ) {
var tween,
collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
index = 0,
length = collection.length;
for ( ; index < length; index++ ) {
if ( (tween = collection[ index ].call( animation, prop, value )) ) {
// we're done with this property
... | Try to determine the default display value of an element
@param {String} nodeName | createTween | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function defaultPrefilter( elem, props, opts ) {
/* jshint validthis: true */
var prop, value, toggle, tween, hooks, oldfire, display, dDisplay,
anim = this,
orig = {},
style = elem.style,
hidden = elem.nodeType && isHidden( elem ),
dataShow = jQuery._data( elem, "fxshow" );
// handle queue: false promise... | Try to determine the default display value of an element
@param {String} nodeName | defaultPrefilter | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function propFilter( props, specialEasing ) {
var index, name, easing, value, hooks;
// camelCase, specialEasing and expand cssHook pass
for ( index in props ) {
name = jQuery.camelCase( index );
easing = specialEasing[ name ];
value = props[ index ];
if ( jQuery.isArray( value ) ) {
easing = value[ 1 ];... | Try to determine the default display value of an element
@param {String} nodeName | propFilter | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function Animation( elem, properties, options ) {
var result,
stopped,
index = 0,
length = animationPrefilters.length,
deferred = jQuery.Deferred().always( function() {
// don't match elem in the :animated selector
delete tick.elem;
}),
tick = function() {
if ( stopped ) {
return false;
}
... | Try to determine the default display value of an element
@param {String} nodeName | Animation | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
tick = function() {
if ( stopped ) {
return false;
}
var currentTime = fxNow || createFxNow(),
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
// archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
temp = remaining / animation.duration || 0,
... | Try to determine the default display value of an element
@param {String} nodeName | tick | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
doAnimation = function() {
// Operate on a copy of prop so per-property easing won't be lost
var anim = Animation( this, jQuery.extend( {}, prop ), optall );
// Empty animations, or finishing resolves immediately
if ( empty || jQuery._data( this, "finish" ) ) {
anim.stop( true );
}
} | Try to determine the default display value of an element
@param {String} nodeName | doAnimation | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
stopQueue = function( hooks ) {
var stop = hooks.stop;
delete hooks.stop;
stop( gotoEnd );
} | Try to determine the default display value of an element
@param {String} nodeName | stopQueue | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function addToPrefiltersOrTransports( structure ) {
// dataTypeExpression is optional and defaults to "*"
return function( dataTypeExpression, func ) {
if ( typeof dataTypeExpression !== "string" ) {
func = dataTypeExpression;
dataTypeExpression = "*";
}
var dataType,
i = 0,
dataTypes = dataTypeE... | Try to determine the default display value of an element
@param {String} nodeName | addToPrefiltersOrTransports | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
var inspected = {},
seekingTransport = ( structure === transports );
function inspect( dataType ) {
var selected;
inspected[ dataType ] = true;
jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {... | Try to determine the default display value of an element
@param {String} nodeName | inspectPrefiltersOrTransports | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function inspect( dataType ) {
var selected;
inspected[ dataType ] = true;
jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !insp... | Try to determine the default display value of an element
@param {String} nodeName | inspect | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function ajaxExtend( target, src ) {
var deep, key,
flatOptions = jQuery.ajaxSettings.flatOptions || {};
for ( key in src ) {
if ( src[ key ] !== undefined ) {
( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
}
}
if ( deep ) {
jQuery.extend( true, target, deep );
}
retur... | Try to determine the default display value of an element
@param {String} nodeName | ajaxExtend | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function ajaxHandleResponses( s, jqXHR, responses ) {
var firstDataType, ct, finalDataType, type,
contents = s.contents,
dataTypes = s.dataTypes;
// Remove auto dataType and get content-type in the process
while ( dataTypes[ 0 ] === "*" ) {
dataTypes.shift();
if ( ct === undefined ) {
ct = s.mimeType || ... | Try to determine the default display value of an element
@param {String} nodeName | ajaxHandleResponses | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function ajaxConvert( s, response, jqXHR, isSuccess ) {
var conv2, current, conv, tmp, prev,
converters = {},
// Work with a copy of dataTypes in case we need to modify it for conversion
dataTypes = s.dataTypes.slice();
// Create converters map with lowercased keys
if ( dataTypes[ 1 ] ) {
for ( conv in s.co... | Try to determine the default display value of an element
@param {String} nodeName | ajaxConvert | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function done( status, nativeStatusText, responses, headers ) {
var isSuccess, success, error, response, modified,
statusText = nativeStatusText;
// Called once
if ( state === 2 ) {
return;
}
// State is "done" now
state = 2;
// Clear timeout if it exists
if ( timeoutTimer ) {
cle... | Try to determine the default display value of an element
@param {String} nodeName | done | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function buildParams( prefix, obj, traditional, add ) {
var name;
if ( jQuery.isArray( obj ) ) {
// Serialize array item.
jQuery.each( obj, function( i, v ) {
if ( traditional || rbracket.test( prefix ) ) {
// Treat each array item as a scalar.
add( prefix, v );
} else {
// Item is non-scalar ... | Try to determine the default display value of an element
@param {String} nodeName | buildParams | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
add = function( key, value ) {
// If value is a function, invoke it and return its value
value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
} | Try to determine the default display value of an element
@param {String} nodeName | add | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function createStandardXHR() {
try {
return new window.XMLHttpRequest();
} catch( e ) {}
} | Try to determine the default display value of an element
@param {String} nodeName | createStandardXHR | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
function createActiveXHR() {
try {
return new window.ActiveXObject( "Microsoft.XMLHTTP" );
} catch( e ) {}
} | Try to determine the default display value of an element
@param {String} nodeName | createActiveXHR | javascript | documentcloud/visualsearch | vendor/jquery-1.11.0.js | https://github.com/documentcloud/visualsearch/blob/master/vendor/jquery-1.11.0.js | MIT |
constructor(request, response, jobs, config) {
const tokens = Object.keys(jobs);
this.config = config;
this.plugins = config.plugins;
this.error = null;
this.statusCode = 200;
// An object that all of the contexts will inherit from... one per instance.
this.baseContext = {
request,
... | The BatchManager is a class that is instantiated once per batch, and holds a lot of the
key data needed throughout the life of the request. This ends up cleaning up some of the
management needed for plugin lifecycle, and the handling of rendering multiple jobs in a
batch.
@param {express.Request} req
@param {express.R... | constructor | javascript | airbnb/hypernova | src/utils/BatchManager.js | https://github.com/airbnb/hypernova/blob/master/src/utils/BatchManager.js | MIT |
getRequestContext(plugin, token) {
return {
...this.baseContext,
...this.jobContexts[token],
...this.pluginContexts.get(plugin),
};
} | Returns a context object scoped to a specific plugin and job (based on the plugin and
job token passed in). | getRequestContext | javascript | airbnb/hypernova | src/utils/BatchManager.js | https://github.com/airbnb/hypernova/blob/master/src/utils/BatchManager.js | MIT |
getBatchContext(plugin) {
return {
...this.baseContext,
...this.batchContext,
...this.pluginContexts.get(plugin),
};
} | Returns a context object scoped to a specific plugin and batch. | getBatchContext | javascript | airbnb/hypernova | src/utils/BatchManager.js | https://github.com/airbnb/hypernova/blob/master/src/utils/BatchManager.js | MIT |
contextFor(plugin, token) {
return token ? this.getRequestContext(plugin, token) : this.getBatchContext(plugin);
} | Returns a context object scoped to a specific plugin and batch. | contextFor | javascript | airbnb/hypernova | src/utils/BatchManager.js | https://github.com/airbnb/hypernova/blob/master/src/utils/BatchManager.js | MIT |
render(token) {
const start = now();
const context = this.jobContexts[token];
const { name } = context;
const { getComponent } = this.config;
const result = getComponent(name, context);
return Promise.resolve(result).then((renderFn) => {
// ensure that we have this component registered
... | Renders a specific job (from a job token). The end result is applied to the corresponding
job context. Additionally, duration is calculated. | render | javascript | airbnb/hypernova | src/utils/BatchManager.js | https://github.com/airbnb/hypernova/blob/master/src/utils/BatchManager.js | MIT |
recordError(error, token) {
if (token && this.jobContexts[token]) {
const context = this.jobContexts[token];
context.statusCode = context.statusCode === 200 ? 500 : context.statusCode;
context.error = error;
} else {
this.error = error;
this.statusCode = 500;
}
} | Renders a specific job (from a job token). The end result is applied to the corresponding
job context. Additionally, duration is calculated. | recordError | javascript | airbnb/hypernova | src/utils/BatchManager.js | https://github.com/airbnb/hypernova/blob/master/src/utils/BatchManager.js | MIT |
getResult(token) {
const context = this.jobContexts[token];
return {
name: context.name,
html: context.html,
meta: context.returnMeta,
duration: context.duration,
statusCode: context.statusCode,
success: context.html !== null,
error: context.error ? errorToSerializable(... | Renders a specific job (from a job token). The end result is applied to the corresponding
job context. Additionally, duration is calculated. | getResult | javascript | airbnb/hypernova | src/utils/BatchManager.js | https://github.com/airbnb/hypernova/blob/master/src/utils/BatchManager.js | MIT |
getResults() {
return {
success: this.error === null,
error: this.error,
results: Object.keys(this.jobContexts).reduce((result, token) => {
/* eslint no-param-reassign: 1 */
result[token] = this.getResult(token);
return result;
}, {}),
};
} | Renders a specific job (from a job token). The end result is applied to the corresponding
job context. Additionally, duration is calculated. | getResults | javascript | airbnb/hypernova | src/utils/BatchManager.js | https://github.com/airbnb/hypernova/blob/master/src/utils/BatchManager.js | MIT |
function hasMethod(name) {
return (obj) => typeof obj[name] === 'function';
} | Returns a predicate function to filter objects based on whether a method of the provided
name is present.
@param {String} name - the method name to find
@returns {Function} - the resulting predicate function | hasMethod | javascript | airbnb/hypernova | src/utils/lifecycle.js | https://github.com/airbnb/hypernova/blob/master/src/utils/lifecycle.js | MIT |
function raceTo(promise, ms, msg) {
let timeout;
return Promise.race([
promise,
new Promise((resolve) => {
timeout = setTimeout(() => resolve(PROMISE_TIMEOUT), ms);
}),
]).then((res) => {
if (res === PROMISE_TIMEOUT) logger.info(msg, { timeout: ms });
if (timeout) clearTimeout(timeout);... | Creates a promise that resolves at the specified number of ms.
@param ms
@returns {Promise} | raceTo | javascript | airbnb/hypernova | src/utils/lifecycle.js | https://github.com/airbnb/hypernova/blob/master/src/utils/lifecycle.js | MIT |
function runAppLifecycle(lifecycle, plugins, config, error, ...args) {
try {
const promise = Promise.all(
plugins.filter(hasMethod(lifecycle)).map((plugin) => plugin[lifecycle](config, error, ...args)),
);
return raceTo(
promise,
MAX_LIFECYCLE_EXECUTION_TIME_IN_MS,
`App lifecycle ... | Iterates through the plugins and calls the specified asynchronous lifecycle event,
returning a promise that resolves when they all are completed, or rejects if one of them
fails.
The third `config` param gets passed into the lifecycle methods as the first argument. In
this case, the app lifecycle events expect the con... | runAppLifecycle | javascript | airbnb/hypernova | src/utils/lifecycle.js | https://github.com/airbnb/hypernova/blob/master/src/utils/lifecycle.js | MIT |
function runLifecycle(lifecycle, plugins, manager, token) {
try {
const promise = Promise.all(
plugins
.filter(hasMethod(lifecycle))
.map((plugin) => plugin[lifecycle](manager.contextFor(plugin, token))),
);
return raceTo(
promise,
MAX_LIFECYCLE_EXECUTION_TIME_IN_MS,
... | Iterates through the plugins and calls the specified asynchronous lifecycle event,
returning a promise that resolves when they are all completed, or rejects if one of them
fails.
This is meant to be used on lifecycle events both at the batch level and the job level. The
passed in BatchManager is used to get the corres... | runLifecycle | javascript | airbnb/hypernova | src/utils/lifecycle.js | https://github.com/airbnb/hypernova/blob/master/src/utils/lifecycle.js | MIT |
function runLifecycleSync(lifecycle, plugins, manager, token) {
plugins
.filter(hasMethod(lifecycle))
.forEach((plugin) => plugin[lifecycle](manager.contextFor(plugin, token)));
} | Iterates through the plugins and calls the specified synchronous lifecycle event (when present).
Passes in the appropriate context object for the plugin/job.
This function is currently being used for `afterRender` and `beforeRender`.
@param {String} lifecycle
@param {Array<HypernovaPlugin>} plugins
@param {BatchManag... | runLifecycleSync | javascript | airbnb/hypernova | src/utils/lifecycle.js | https://github.com/airbnb/hypernova/blob/master/src/utils/lifecycle.js | MIT |
function errorSync(err, plugins, manager, token) {
plugins
.filter(hasMethod('onError'))
.forEach((plugin) => plugin.onError(manager.contextFor(plugin, token), err));
} | Iterates through the plugins and calls the specified synchronous `onError` handler
(when present).
Passes in the appropriate context object, as well as the error.
@param {Error} err
@param {Array<HypernovaPlugin>} plugins
@param {BatchManager} manager
@param {String} [token] | errorSync | javascript | airbnb/hypernova | src/utils/lifecycle.js | https://github.com/airbnb/hypernova/blob/master/src/utils/lifecycle.js | MIT |
function processJob(token, plugins, manager) {
return (
// jobStart
runLifecycle('jobStart', plugins, manager, token)
.then(() => {
// beforeRender
runLifecycleSync('beforeRender', plugins, manager, token);
// render
return manager.render(token);
})
// jobEn... | Runs through the job-level lifecycle events of the job based on the provided token. This includes
the actual rendering of the job.
Returns a promise resolving when the job completes.
@param {String} token
@param {Array<HypernovaPlugin>} plugins
@param {BatchManager} manager
@returns {Promise} | processJob | javascript | airbnb/hypernova | src/utils/lifecycle.js | https://github.com/airbnb/hypernova/blob/master/src/utils/lifecycle.js | MIT |
function processJobsSerially(jobs, plugins, manager) {
return Object.keys(jobs).reduce(
(chain, token) => chain.then(() => processJob(token, plugins, manager)),
Promise.resolve(),
);
} | Runs through the job-level lifecycle events of the job based on the provided token. This includes
the actual rendering of the job.
Returns a promise resolving when the job completes.
@param {String} token
@param {Array<HypernovaPlugin>} plugins
@param {BatchManager} manager
@returns {Promise} | processJobsSerially | javascript | airbnb/hypernova | src/utils/lifecycle.js | https://github.com/airbnb/hypernova/blob/master/src/utils/lifecycle.js | MIT |
function processJobsConcurrently(jobs, plugins, manager) {
return Promise.all(
Object.keys(jobs).map((token) => processJob(token, plugins, manager)),
);
} | Runs through the job-level lifecycle events of the job based on the provided token. This includes
the actual rendering of the job.
Returns a promise resolving when the job completes.
@param {String} token
@param {Array<HypernovaPlugin>} plugins
@param {BatchManager} manager
@returns {Promise} | processJobsConcurrently | javascript | airbnb/hypernova | src/utils/lifecycle.js | https://github.com/airbnb/hypernova/blob/master/src/utils/lifecycle.js | MIT |
function processBatch(jobs, plugins, manager, concurrent) {
return (
// batchStart
runLifecycle('batchStart', plugins, manager)
// for each job, processJob
.then(() => {
if (concurrent) {
return processJobsConcurrently(jobs, plugins, manager);
}
return processJo... | Runs through the batch-level lifecycle events of a batch. This includes the processing of each
individual job.
Returns a promise resolving when all jobs in the batch complete.
@param jobs
@param {Array<HypernovaPlugin>} plugins
@param {BatchManager} manager
@returns {Promise} | processBatch | javascript | airbnb/hypernova | src/utils/lifecycle.js | https://github.com/airbnb/hypernova/blob/master/src/utils/lifecycle.js | MIT |
function require(path, parent, orig) {
var resolved = require.resolve(path);
// lookup failed
if (null == resolved) {
orig = orig || path;
parent = parent || 'root';
var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');
err.path = orig;
err.parent = parent;
err.re... | Require the given path.
@param {String} path
@return {Object} exports
@api public | require | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
copyArray = function(dest, doffset, src, soffset, length) {
if('function' === typeof src.copy) {
// Buffer
src.copy(dest, doffset, soffset, soffset + length);
} else {
// Uint8Array
for(var index=0; index<length; index++){
dest[doffset++] = src[soffset++];
}
}
} | Message protocol decode.
@param {Buffer|Uint8Array} buffer message bytes
@return {Object} message object | copyArray | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
msgHasId = function(type) {
return type === Message.TYPE_REQUEST || type === Message.TYPE_RESPONSE;
} | Message protocol decode.
@param {Buffer|Uint8Array} buffer message bytes
@return {Object} message object | msgHasId | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
msgHasRoute = function(type) {
return type === Message.TYPE_REQUEST || type === Message.TYPE_NOTIFY ||
type === Message.TYPE_PUSH;
} | Message protocol decode.
@param {Buffer|Uint8Array} buffer message bytes
@return {Object} message object | msgHasRoute | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
caculateMsgIdBytes = function(id) {
var len = 0;
do {
len += 1;
id >>= 7;
} while(id > 0);
return len;
} | Message protocol decode.
@param {Buffer|Uint8Array} buffer message bytes
@return {Object} message object | caculateMsgIdBytes | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
encodeMsgFlag = function(type, compressRoute, buffer, offset) {
if(type !== Message.TYPE_REQUEST && type !== Message.TYPE_NOTIFY &&
type !== Message.TYPE_RESPONSE && type !== Message.TYPE_PUSH) {
throw new Error('unkonw message type: ' + type);
}
buffer[offset] = (type << 1) | (compressRoute ?... | Message protocol decode.
@param {Buffer|Uint8Array} buffer message bytes
@return {Object} message object | encodeMsgFlag | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
encodeMsgId = function(id, idBytes, buffer, offset) {
var index = offset + idBytes - 1;
buffer[index--] = id & 0x7f;
while(index >= offset) {
id >>= 7;
buffer[index--] = id & 0x7f | 0x80;
}
return offset + idBytes;
} | Message protocol decode.
@param {Buffer|Uint8Array} buffer message bytes
@return {Object} message object | encodeMsgId | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
encodeMsgRoute = function(compressRoute, route, buffer, offset) {
if (compressRoute) {
if(route > MSG_ROUTE_CODE_MAX){
throw new Error('route number is overflow');
}
buffer[offset++] = (route >> 8) & 0xff;
buffer[offset++] = route & 0xff;
} else {
if(route) {
buffe... | Message protocol decode.
@param {Buffer|Uint8Array} buffer message bytes
@return {Object} message object | encodeMsgRoute | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
encodeMsgBody = function(msg, buffer, offset) {
copyArray(buffer, offset, msg, 0, msg.length);
return offset + msg.length;
} | Message protocol decode.
@param {Buffer|Uint8Array} buffer message bytes
@return {Object} message object | encodeMsgBody | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
function checkMsg(msg, protos){
if(!protos){
return false;
}
for(var name in protos){
var proto = protos[name];
//All required element must exist
switch(proto.option){
case 'required' :
if(typeof(msg[name]) === 'undefined'){
return false;
}
... | Check if the msg follow the defination in the protos | checkMsg | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
function encodeMsg(buffer, offset, protos, msg){
for(var name in msg){
if(!!protos[name]){
var proto = protos[name];
switch(proto.option){
case 'required' :
case 'optional' :
offset = writeBytes(buffer, offset, encodeTag(proto.type, proto.tag));
off... | Check if the msg follow the defination in the protos | encodeMsg | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
function encodeProp(value, type, offset, buffer, protos){
switch(type){
case 'uInt32':
offset = writeBytes(buffer, offset, codec.encodeUInt32(value));
break;
case 'int32' :
case 'sInt32':
offset = writeBytes(buffer, offset, codec.encodeSInt32(value));
break;
case ... | Check if the msg follow the defination in the protos | encodeProp | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
function encodeArray(array, proto, offset, buffer, protos){
var i = 0;
if(util.isSimpleType(proto.type)){
offset = writeBytes(buffer, offset, encodeTag(proto.type, proto.tag));
offset = writeBytes(buffer, offset, codec.encodeUInt32(array.length));
for(i = 0; i < array.length; i++){
of... | Encode reapeated properties, simple msg and object are decode differented | encodeArray | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
function writeBytes(buffer, offset, bytes){
for(var i = 0; i < bytes.length; i++, offset++){
buffer[offset] = bytes[i];
}
return offset;
} | Encode reapeated properties, simple msg and object are decode differented | writeBytes | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
function encodeTag(type, tag){
var value = constant.TYPES[type]||2;
return codec.encodeUInt32((tag<<3)|value);
} | Encode reapeated properties, simple msg and object are decode differented | encodeTag | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
function isFinish(msg, protos){
return (!protos.__tags[peekHead().tag]);
} | Test if the given msg is finished | isFinish | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
function peekHead(){
var tag = codec.decodeUInt32(peekBytes());
return {
type : tag&0x7,
tag : tag>>3
};
} | Get tag head without move the offset | peekHead | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
function decodeProp(type, protos){
switch(type){
case 'uInt32':
return codec.decodeUInt32(getBytes());
case 'int32' :
case 'sInt32' :
return codec.decodeSInt32(getBytes());
case 'float' :
var float = codec.decodeFloat(buffer, offset);
offset += 4;
retu... | Get tag head without move the offset | decodeProp | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
function decodeArray(array, type, protos){
if(util.isSimpleType(type)){
var length = codec.decodeUInt32(getBytes());
for(var i = 0; i < length; i++){
array.push(decodeProp(type));
}
}else{
array.push(decodeProp(type, protos));
}
} | Get tag head without move the offset | decodeArray | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
function getBytes(flag){
var bytes = [];
var pos = offset;
flag = flag || false;
var b;
do{
b = buffer[pos];
bytes.push(b);
pos++;
}while(b >= 128);
if(!flag){
offset = pos;
}
return bytes;
} | Get tag head without move the offset | getBytes | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
function peekBytes(){
return getBytes(true);
} | Get tag head without move the offset | peekBytes | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
initWebSocket = function(url,cb) {
console.log('connect to ' + url);
var onopen = function(event){
var obj = Package.encode(Package.TYPE_HANDSHAKE, Protocol.strencode(JSON.stringify(handshakeBuffer)));
send(obj);
};
var onmessage = function(event) {
processPackage(Package.decode(event.... | Get tag head without move the offset | initWebSocket | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
onopen = function(event){
var obj = Package.encode(Package.TYPE_HANDSHAKE, Protocol.strencode(JSON.stringify(handshakeBuffer)));
send(obj);
} | Get tag head without move the offset | onopen | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
onmessage = function(event) {
processPackage(Package.decode(event.data), cb);
// new package arrived, update the heartbeat timeout
if(heartbeatTimeout) {
nextHeartbeatTimeout = Date.now() + heartbeatTimeout;
}
} | Get tag head without move the offset | onmessage | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
onerror = function(event) {
pinus.emit('io-error', event);
console.error('socket error: ', event);
} | Get tag head without move the offset | onerror | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
onclose = function(event){
pinus.emit('close',event);
console.error('socket close: ', event);
} | Get tag head without move the offset | onclose | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
sendMessage = function(reqId, route, msg) {
var type = reqId ? Message.TYPE_REQUEST : Message.TYPE_NOTIFY;
//compress message by protobuf
var protos = !!pinus.data.protos?pinus.data.protos.client:{};
if(!!protos[route]){
msg = protobuf.encode(route, msg);
}else{
msg = Protocol.strencode... | Get tag head without move the offset | sendMessage | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
heartbeat = function(data) {
if(!heartbeatInterval) {
// no heartbeat
return;
}
var obj = Package.encode(Package.TYPE_HEARTBEAT);
if(heartbeatTimeoutId) {
clearTimeout(heartbeatTimeoutId);
heartbeatTimeoutId = null;
}
if(heartbeatId) {
// already in a heartbeat in... | Get tag head without move the offset | heartbeat | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
heartbeatTimeoutCb = function() {
var gap = nextHeartbeatTimeout - Date.now();
if(gap > gapThreshold) {
heartbeatTimeoutId = setTimeout(heartbeatTimeoutCb, gap);
} else {
console.error('server heartbeat timeout');
pinus.emit('heartbeat timeout');
pinus.disconnect();
}
} | Get tag head without move the offset | heartbeatTimeoutCb | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
handshake = function(data){
data = JSON.parse(Protocol.strdecode(data));
if(data.code === RES_OLD_CLIENT) {
pinus.emit('error', 'client version not fullfill');
return;
}
if(data.code !== RES_OK) {
pinus.emit('error', 'handshake fail');
return;
}
handshakeInit(data);
... | Get tag head without move the offset | handshake | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
onData = function(data){
//probuff decode
var msg = Message.decode(data);
if(msg.id > 0){
msg.route = routeMap[msg.id];
delete routeMap[msg.id];
if(!msg.route){
return;
}
}
msg.body = deCompose(msg);
processMessage(pinus, msg);
} | Get tag head without move the offset | onData | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
processMessage = function(pinus, msg) {
if(!msg.id) {
// server push message
pinus.emit(msg.route, msg.body);
return;
}
//if have a id then find the callback function with the request
var cb = callbacks[msg.id];
delete callbacks[msg.id];
if(typeof cb !== 'function') {
r... | Get tag head without move the offset | processMessage | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
processMessageBatch = function(pinus, msgs) {
for(var i=0, l=msgs.length; i<l; i++) {
processMessage(pinus, msgs[i]);
}
} | Get tag head without move the offset | processMessageBatch | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
deCompose = function(msg){
var protos = !!pinus.data.protos?pinus.data.protos.server:{};
var abbrs = pinus.data.abbrs;
var route = msg.route;
//Decompose route from dict
if(msg.compressRoute) {
if(!abbrs[route]){
return {};
}
route = msg.route = abbrs[route];
}
if... | Get tag head without move the offset | deCompose | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
handshakeInit = function(data){
if(data.sys && data.sys.heartbeat) {
heartbeatInterval = data.sys.heartbeat * 1000; // heartbeat interval
heartbeatTimeout = heartbeatInterval * 2; // max heartbeat timeout
} else {
heartbeatInterval = 0;
heartbeatTimeout = 0;
}
initData(... | Get tag head without move the offset | handshakeInit | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
initData = function(data){
if(!data || !data.sys) {
return;
}
pinus.data = pinus.data || {};
var dict = data.sys.dict;
var protos = data.sys.protos;
//Init compress dict
if(dict){
pinus.data.dict = dict;
pinus.data.abbrs = {};
for(var route in dict){
pinus.d... | Get tag head without move the offset | initData | javascript | node-pinus/pinus | examples/simple-example/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/simple-example/web-server/public/js/lib/build/build.js | MIT |
function require(path, parent, orig) {
var resolved = require.resolve(path);
// lookup failed
if (null == resolved) {
orig = orig || path;
parent = parent || 'root';
var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');
err.path = orig;
err.parent = parent;
err.re... | Require the given path.
@param {String} path
@return {Object} exports
@api public | require | javascript | node-pinus/pinus | examples/ssl-connector/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/ssl-connector/web-server/public/js/lib/build/build.js | MIT |
copyArray = function(dest, doffset, src, soffset, length) {
if('function' === typeof src.copy) {
// Buffer
src.copy(dest, doffset, soffset, soffset + length);
} else {
// Uint8Array
for(var index=0; index<length; index++){
dest[doffset++] = src[soffset++];
}
}
} | Message protocol decode.
@param {Buffer|Uint8Array} buffer message bytes
@return {Object} message object | copyArray | javascript | node-pinus/pinus | examples/ssl-connector/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/ssl-connector/web-server/public/js/lib/build/build.js | MIT |
msgHasId = function(type) {
return type === Message.TYPE_REQUEST || type === Message.TYPE_RESPONSE;
} | Message protocol decode.
@param {Buffer|Uint8Array} buffer message bytes
@return {Object} message object | msgHasId | javascript | node-pinus/pinus | examples/ssl-connector/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/ssl-connector/web-server/public/js/lib/build/build.js | MIT |
msgHasRoute = function(type) {
return type === Message.TYPE_REQUEST || type === Message.TYPE_NOTIFY ||
type === Message.TYPE_PUSH;
} | Message protocol decode.
@param {Buffer|Uint8Array} buffer message bytes
@return {Object} message object | msgHasRoute | javascript | node-pinus/pinus | examples/ssl-connector/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/ssl-connector/web-server/public/js/lib/build/build.js | MIT |
caculateMsgIdBytes = function(id) {
var len = 0;
do {
len += 1;
id >>= 7;
} while(id > 0);
return len;
} | Message protocol decode.
@param {Buffer|Uint8Array} buffer message bytes
@return {Object} message object | caculateMsgIdBytes | javascript | node-pinus/pinus | examples/ssl-connector/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/ssl-connector/web-server/public/js/lib/build/build.js | MIT |
encodeMsgFlag = function(type, compressRoute, buffer, offset) {
if(type !== Message.TYPE_REQUEST && type !== Message.TYPE_NOTIFY &&
type !== Message.TYPE_RESPONSE && type !== Message.TYPE_PUSH) {
throw new Error('unkonw message type: ' + type);
}
buffer[offset] = (type << 1) | (compressRoute ?... | Message protocol decode.
@param {Buffer|Uint8Array} buffer message bytes
@return {Object} message object | encodeMsgFlag | javascript | node-pinus/pinus | examples/ssl-connector/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/ssl-connector/web-server/public/js/lib/build/build.js | MIT |
encodeMsgId = function(id, idBytes, buffer, offset) {
var index = offset + idBytes - 1;
buffer[index--] = id & 0x7f;
while(index >= offset) {
id >>= 7;
buffer[index--] = id & 0x7f | 0x80;
}
return offset + idBytes;
} | Message protocol decode.
@param {Buffer|Uint8Array} buffer message bytes
@return {Object} message object | encodeMsgId | javascript | node-pinus/pinus | examples/ssl-connector/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/ssl-connector/web-server/public/js/lib/build/build.js | MIT |
encodeMsgRoute = function(compressRoute, route, buffer, offset) {
if (compressRoute) {
if(route > MSG_ROUTE_CODE_MAX){
throw new Error('route number is overflow');
}
buffer[offset++] = (route >> 8) & 0xff;
buffer[offset++] = route & 0xff;
} else {
if(route) {
buffe... | Message protocol decode.
@param {Buffer|Uint8Array} buffer message bytes
@return {Object} message object | encodeMsgRoute | javascript | node-pinus/pinus | examples/ssl-connector/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/ssl-connector/web-server/public/js/lib/build/build.js | MIT |
encodeMsgBody = function(msg, buffer, offset) {
copyArray(buffer, offset, msg, 0, msg.length);
return offset + msg.length;
} | Message protocol decode.
@param {Buffer|Uint8Array} buffer message bytes
@return {Object} message object | encodeMsgBody | javascript | node-pinus/pinus | examples/ssl-connector/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/ssl-connector/web-server/public/js/lib/build/build.js | MIT |
function checkMsg(msg, protos){
if(!protos){
return false;
}
for(var name in protos){
var proto = protos[name];
//All required element must exist
switch(proto.option){
case 'required' :
if(typeof(msg[name]) === 'undefined'){
return false;
}
... | Check if the msg follow the defination in the protos | checkMsg | javascript | node-pinus/pinus | examples/ssl-connector/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/ssl-connector/web-server/public/js/lib/build/build.js | MIT |
function encodeMsg(buffer, offset, protos, msg){
for(var name in msg){
if(!!protos[name]){
var proto = protos[name];
switch(proto.option){
case 'required' :
case 'optional' :
offset = writeBytes(buffer, offset, encodeTag(proto.type, proto.tag));
off... | Check if the msg follow the defination in the protos | encodeMsg | javascript | node-pinus/pinus | examples/ssl-connector/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/ssl-connector/web-server/public/js/lib/build/build.js | MIT |
function encodeProp(value, type, offset, buffer, protos){
switch(type){
case 'uInt32':
offset = writeBytes(buffer, offset, codec.encodeUInt32(value));
break;
case 'int32' :
case 'sInt32':
offset = writeBytes(buffer, offset, codec.encodeSInt32(value));
break;
case ... | Check if the msg follow the defination in the protos | encodeProp | javascript | node-pinus/pinus | examples/ssl-connector/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/ssl-connector/web-server/public/js/lib/build/build.js | MIT |
function encodeArray(array, proto, offset, buffer, protos){
var i = 0;
if(util.isSimpleType(proto.type)){
offset = writeBytes(buffer, offset, encodeTag(proto.type, proto.tag));
offset = writeBytes(buffer, offset, codec.encodeUInt32(array.length));
for(i = 0; i < array.length; i++){
of... | Encode reapeated properties, simple msg and object are decode differented | encodeArray | javascript | node-pinus/pinus | examples/ssl-connector/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/ssl-connector/web-server/public/js/lib/build/build.js | MIT |
function writeBytes(buffer, offset, bytes){
for(var i = 0; i < bytes.length; i++, offset++){
buffer[offset] = bytes[i];
}
return offset;
} | Encode reapeated properties, simple msg and object are decode differented | writeBytes | javascript | node-pinus/pinus | examples/ssl-connector/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/ssl-connector/web-server/public/js/lib/build/build.js | MIT |
function encodeTag(type, tag){
var value = constant.TYPES[type]||2;
return codec.encodeUInt32((tag<<3)|value);
} | Encode reapeated properties, simple msg and object are decode differented | encodeTag | javascript | node-pinus/pinus | examples/ssl-connector/web-server/public/js/lib/build/build.js | https://github.com/node-pinus/pinus/blob/master/examples/ssl-connector/web-server/public/js/lib/build/build.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.