<commit_before>/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

/*
* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.
*/

// MODULES //

var setReadOnly = require( '@stdlib/utils/define-read-only-property' );

// MAIN //

/**
* Top-level namespace.
*
* @namespace ns
*/
var ns = {};

/**
* @name arcsine
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/arcsine}
*/
setReadOnly( ns, 'arcsine', require( '@stdlib/random/streams/arcsine' ) );

/**
* @name bernoulli
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/bernoulli}
*/
setReadOnly( ns, 'bernoulli', require( '@stdlib/random/streams/bernoulli' ) );

/**
* @name beta
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/beta}
*/
setReadOnly( ns, 'beta', require( '@stdlib/random/streams/beta' ) );

/**
* @name betaprime
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/betaprime}
*/
setReadOnly( ns, 'betaprime', require( '@stdlib/random/streams/betaprime' ) );

/**
* @name boxMuller
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/box-muller}
*/
setReadOnly( ns, 'boxMuller', require( '@stdlib/random/streams/box-muller' ) );

/**
* @name cauchy
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/cauchy}
*/
setReadOnly( ns, 'cauchy', require( '@stdlib/random/streams/cauchy' ) );

/**
* @name chi
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/chi}
*/
setReadOnly( ns, 'chi', require( '@stdlib/random/streams/chi' ) );

/**
* @name chisquare
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/chisquare}
*/
setReadOnly( ns, 'chisquare', require( '@stdlib/random/streams/chisquare' ) );

/**
* @name cosine
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/cosine}
*/
setReadOnly( ns, 'cosine', require( '@stdlib/random/streams/cosine' ) );

/**
* @name discreteUniform
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/discrete-uniform}
*/
setReadOnly( ns, 'discreteUniform', require( '@stdlib/random/streams/discrete-uniform' ) );

/**
* @name erlang
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/erlang}
*/
setReadOnly( ns, 'erlang', require( '@stdlib/random/streams/erlang' ) );

/**
* @name exponential
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/exponential}
*/
setReadOnly( ns, 'exponential', require( '@stdlib/random/streams/exponential' ) );

/**
* @name f
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/f}
*/
setReadOnly( ns, 'f', require( '@stdlib/random/streams/f' ) );

/**
* @name gamma
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/gamma}
*/
setReadOnly( ns, 'gamma', require( '@stdlib/random/streams/gamma' ) );

/**
* @name geometric
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/geometric}
*/
setReadOnly( ns, 'geometric', require( '@stdlib/random/streams/geometric' ) );

/**
* @name gumbel
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/gumbel}
*/
setReadOnly( ns, 'gumbel', require( '@stdlib/random/streams/gumbel' ) );

/**
* @name improvedZiggurat
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/improved-ziggurat}
*/
setReadOnly( ns, 'improvedZiggurat', require( '@stdlib/random/streams/improved-ziggurat' ) );

/**
* @name invgamma
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/invgamma}
*/
setReadOnly( ns, 'invgamma', require( '@stdlib/random/streams/invgamma' ) );

/**
* @name kumaraswamy
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/kumaraswamy}
*/
setReadOnly( ns, 'kumaraswamy', require( '@stdlib/random/streams/kumaraswamy' ) );

/**
* @name laplace
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/laplace}
*/
setReadOnly( ns, 'laplace', require( '@stdlib/random/streams/laplace' ) );

/**
* @name levy
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/levy}
*/
setReadOnly( ns, 'levy', require( '@stdlib/random/streams/levy' ) );

/**
* @name logistic
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/logistic}
*/
setReadOnly( ns, 'logistic', require( '@stdlib/random/streams/logistic' ) );

/**
* @name lognormal
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/lognormal}
*/
setReadOnly( ns, 'lognormal', require( '@stdlib/random/streams/lognormal' ) );

/**
* @name minstd
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/minstd}
*/
setReadOnly( ns, 'minstd', require( '@stdlib/random/streams/minstd' ) );

/**
* @name minstdShuffle
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/minstd-shuffle}
*/
setReadOnly( ns, 'minstdShuffle', require( '@stdlib/random/streams/minstd-shuffle' ) );

/**
* @name mt19937
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/mt19937}
*/
setReadOnly( ns, 'mt19937', require( '@stdlib/random/streams/mt19937' ) );

/**
* @name normal
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/normal}
*/
setReadOnly( ns, 'normal', require( '@stdlib/random/streams/normal' ) );

/**
* @name poisson
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/poisson}
*/
setReadOnly( ns, 'poisson', require( '@stdlib/random/streams/poisson' ) );

/**
* @name randi
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/randi}
*/
setReadOnly( ns, 'randi', require( '@stdlib/random/streams/randi' ) );

/**
* @name randn
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/randn}
*/
setReadOnly( ns, 'randn', require( '@stdlib/random/streams/randn' ) );

/**
* @name randu
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/randu}
*/
setReadOnly( ns, 'randu', require( '@stdlib/random/streams/randu' ) );

/**
* @name rayleigh
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/rayleigh}
*/
setReadOnly( ns, 'rayleigh', require( '@stdlib/random/streams/rayleigh' ) );

/**
* @name t
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/t}
*/
setReadOnly( ns, 't', require( '@stdlib/random/streams/t' ) );

/**
* @name uniform
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/uniform}
*/
setReadOnly( ns, 'uniform', require( '@stdlib/random/streams/uniform' ) );

/**
* @name weibull
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/weibull}
*/
setReadOnly( ns, 'weibull', require( '@stdlib/random/streams/weibull' ) );

// EXPORTS //

module.exports = ns;
<commit_msg>Add package to streams namespace<commit_after>/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

/*
* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.
*/

// MODULES //

var setReadOnly = require( '@stdlib/utils/define-read-only-property' );

// MAIN //

/**
* Top-level namespace.
*
* @namespace ns
*/
var ns = {};

/**
* @name arcsine
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/arcsine}
*/
setReadOnly( ns, 'arcsine', require( '@stdlib/random/streams/arcsine' ) );

/**
* @name bernoulli
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/bernoulli}
*/
setReadOnly( ns, 'bernoulli', require( '@stdlib/random/streams/bernoulli' ) );

/**
* @name beta
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/beta}
*/
setReadOnly( ns, 'beta', require( '@stdlib/random/streams/beta' ) );

/**
* @name betaprime
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/betaprime}
*/
setReadOnly( ns, 'betaprime', require( '@stdlib/random/streams/betaprime' ) );

/**
* @name boxMuller
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/box-muller}
*/
setReadOnly( ns, 'boxMuller', require( '@stdlib/random/streams/box-muller' ) );

/**
* @name cauchy
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/cauchy}
*/
setReadOnly( ns, 'cauchy', require( '@stdlib/random/streams/cauchy' ) );

/**
* @name chi
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/chi}
*/
setReadOnly( ns, 'chi', require( '@stdlib/random/streams/chi' ) );

/**
* @name chisquare
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/chisquare}
*/
setReadOnly( ns, 'chisquare', require( '@stdlib/random/streams/chisquare' ) );

/**
* @name cosine
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/cosine}
*/
setReadOnly( ns, 'cosine', require( '@stdlib/random/streams/cosine' ) );

/**
* @name discreteUniform
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/discrete-uniform}
*/
setReadOnly( ns, 'discreteUniform', require( '@stdlib/random/streams/discrete-uniform' ) );

/**
* @name erlang
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/erlang}
*/
setReadOnly( ns, 'erlang', require( '@stdlib/random/streams/erlang' ) );

/**
* @name exponential
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/exponential}
*/
setReadOnly( ns, 'exponential', require( '@stdlib/random/streams/exponential' ) );

/**
* @name f
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/f}
*/
setReadOnly( ns, 'f', require( '@stdlib/random/streams/f' ) );

/**
* @name gamma
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/gamma}
*/
setReadOnly( ns, 'gamma', require( '@stdlib/random/streams/gamma' ) );

/**
* @name geometric
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/geometric}
*/
setReadOnly( ns, 'geometric', require( '@stdlib/random/streams/geometric' ) );

/**
* @name gumbel
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/gumbel}
*/
setReadOnly( ns, 'gumbel', require( '@stdlib/random/streams/gumbel' ) );

/**
* @name improvedZiggurat
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/improved-ziggurat}
*/
setReadOnly( ns, 'improvedZiggurat', require( '@stdlib/random/streams/improved-ziggurat' ) );

/**
* @name invgamma
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/invgamma}
*/
setReadOnly( ns, 'invgamma', require( '@stdlib/random/streams/invgamma' ) );

/**
* @name kumaraswamy
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/kumaraswamy}
*/
setReadOnly( ns, 'kumaraswamy', require( '@stdlib/random/streams/kumaraswamy' ) );

/**
* @name laplace
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/laplace}
*/
setReadOnly( ns, 'laplace', require( '@stdlib/random/streams/laplace' ) );

/**
* @name levy
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/levy}
*/
setReadOnly( ns, 'levy', require( '@stdlib/random/streams/levy' ) );

/**
* @name logistic
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/logistic}
*/
setReadOnly( ns, 'logistic', require( '@stdlib/random/streams/logistic' ) );

/**
* @name lognormal
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/lognormal}
*/
setReadOnly( ns, 'lognormal', require( '@stdlib/random/streams/lognormal' ) );

/**
* @name minstd
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/minstd}
*/
setReadOnly( ns, 'minstd', require( '@stdlib/random/streams/minstd' ) );

/**
* @name minstdShuffle
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/minstd-shuffle}
*/
setReadOnly( ns, 'minstdShuffle', require( '@stdlib/random/streams/minstd-shuffle' ) );

/**
* @name mt19937
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/mt19937}
*/
setReadOnly( ns, 'mt19937', require( '@stdlib/random/streams/mt19937' ) );

/**
* @name normal
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/normal}
*/
setReadOnly( ns, 'normal', require( '@stdlib/random/streams/normal' ) );

/**
* @name pareto1
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/pareto-type1}
*/
setReadOnly( ns, 'pareto1', require( '@stdlib/random/streams/pareto-type1' ) );

/**
* @name poisson
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/poisson}
*/
setReadOnly( ns, 'poisson', require( '@stdlib/random/streams/poisson' ) );

/**
* @name randi
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/randi}
*/
setReadOnly( ns, 'randi', require( '@stdlib/random/streams/randi' ) );

/**
* @name randn
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/randn}
*/
setReadOnly( ns, 'randn', require( '@stdlib/random/streams/randn' ) );

/**
* @name randu
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/randu}
*/
setReadOnly( ns, 'randu', require( '@stdlib/random/streams/randu' ) );

/**
* @name rayleigh
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/rayleigh}
*/
setReadOnly( ns, 'rayleigh', require( '@stdlib/random/streams/rayleigh' ) );

/**
* @name t
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/t}
*/
setReadOnly( ns, 't', require( '@stdlib/random/streams/t' ) );

/**
* @name uniform
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/uniform}
*/
setReadOnly( ns, 'uniform', require( '@stdlib/random/streams/uniform' ) );

/**
* @name weibull
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/weibull}
*/
setReadOnly( ns, 'weibull', require( '@stdlib/random/streams/weibull' ) );

// EXPORTS //

module.exports = ns;
<|endoftext|>


<commit_before>/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

/*
* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.
*/

// MODULES //

var setReadOnly = require( '@stdlib/utils/define-read-only-property' );

// MAIN //

/**
* Top-level namespace.
*
* @namespace ns
*/
var ns = {};

/**
* @name arcsine
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/arcsine}
*/
setReadOnly( ns, 'arcsine', require( '@stdlib/random/streams/arcsine' ) );

/**
* @name improvedZiggurat
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/improved-ziggurat}
*/
setReadOnly( ns, 'improvedZiggurat', require( '@stdlib/random/streams/improved-ziggurat' ) );

/**
* @name minstd
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/minstd}
*/
setReadOnly( ns, 'minstd', require( '@stdlib/random/streams/minstd' ) );

/**
* @name minstdShuffle
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/minstd-shuffle}
*/
setReadOnly( ns, 'minstdShuffle', require( '@stdlib/random/streams/minstd-shuffle' ) );

/**
* @name mt19937
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/mt19937}
*/
setReadOnly( ns, 'mt19937', require( '@stdlib/random/streams/mt19937' ) );

// EXPORTS //

module.exports = ns;
<commit_msg>Update namespace<commit_after>/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

/*
* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.
*/

// MODULES //

var setReadOnly = require( '@stdlib/utils/define-read-only-property' );

// MAIN //

/**
* Top-level namespace.
*
* @namespace ns
*/
var ns = {};

/**
* @name arcsine
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/arcsine}
*/
setReadOnly( ns, 'arcsine', require( '@stdlib/random/streams/arcsine' ) );

/**
* @name boxMuller
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/box-muller}
*/
setReadOnly( ns, 'boxMuller', require( '@stdlib/random/streams/box-muller' ) );

/**
* @name improvedZiggurat
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/improved-ziggurat}
*/
setReadOnly( ns, 'improvedZiggurat', require( '@stdlib/random/streams/improved-ziggurat' ) );

/**
* @name minstd
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/minstd}
*/
setReadOnly( ns, 'minstd', require( '@stdlib/random/streams/minstd' ) );

/**
* @name minstdShuffle
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/minstd-shuffle}
*/
setReadOnly( ns, 'minstdShuffle', require( '@stdlib/random/streams/minstd-shuffle' ) );

/**
* @name mt19937
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/mt19937}
*/
setReadOnly( ns, 'mt19937', require( '@stdlib/random/streams/mt19937' ) );

// EXPORTS //

module.exports = ns;
<|endoftext|>


<commit_before>/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

/*
* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.
*/

// MODULES //

var setReadOnly = require( '@stdlib/utils/define-read-only-property' );

// MAIN //

/**
* Top-level namespace.
*
* @namespace ns
*/
var ns = {};

/**
* @name arcsine
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/arcsine}
*/
setReadOnly( ns, 'arcsine', require( '@stdlib/random/streams/arcsine' ) );

/**
* @name boxMuller
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/box-muller}
*/
setReadOnly( ns, 'boxMuller', require( '@stdlib/random/streams/box-muller' ) );

/**
* @name improvedZiggurat
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/improved-ziggurat}
*/
setReadOnly( ns, 'improvedZiggurat', require( '@stdlib/random/streams/improved-ziggurat' ) );

/**
* @name minstd
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/minstd}
*/
setReadOnly( ns, 'minstd', require( '@stdlib/random/streams/minstd' ) );

/**
* @name minstdShuffle
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/minstd-shuffle}
*/
setReadOnly( ns, 'minstdShuffle', require( '@stdlib/random/streams/minstd-shuffle' ) );

/**
* @name mt19937
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/mt19937}
*/
setReadOnly( ns, 'mt19937', require( '@stdlib/random/streams/mt19937' ) );

/**
* @name randi
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/randi}
*/
setReadOnly( ns, 'randi', require( '@stdlib/random/streams/randi' ) );

// EXPORTS //

module.exports = ns;
<commit_msg>Update namespace<commit_after>/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

/*
* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.
*/

// MODULES //

var setReadOnly = require( '@stdlib/utils/define-read-only-property' );

// MAIN //

/**
* Top-level namespace.
*
* @namespace ns
*/
var ns = {};

/**
* @name arcsine
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/arcsine}
*/
setReadOnly( ns, 'arcsine', require( '@stdlib/random/streams/arcsine' ) );

/**
* @name boxMuller
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/box-muller}
*/
setReadOnly( ns, 'boxMuller', require( '@stdlib/random/streams/box-muller' ) );

/**
* @name improvedZiggurat
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/improved-ziggurat}
*/
setReadOnly( ns, 'improvedZiggurat', require( '@stdlib/random/streams/improved-ziggurat' ) );

/**
* @name minstd
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/minstd}
*/
setReadOnly( ns, 'minstd', require( '@stdlib/random/streams/minstd' ) );

/**
* @name minstdShuffle
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/minstd-shuffle}
*/
setReadOnly( ns, 'minstdShuffle', require( '@stdlib/random/streams/minstd-shuffle' ) );

/**
* @name mt19937
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/mt19937}
*/
setReadOnly( ns, 'mt19937', require( '@stdlib/random/streams/mt19937' ) );

/**
* @name randi
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/randi}
*/
setReadOnly( ns, 'randi', require( '@stdlib/random/streams/randi' ) );

/**
* @name randu
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/random/streams/randu}
*/
setReadOnly( ns, 'randu', require( '@stdlib/random/streams/randu' ) );

// EXPORTS //

module.exports = ns;
<|endoftext|>


<commit_before>/**
* Copyright 2011 Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Module dependencies.
var util = require('util');

var azureutil = require('../../../util/util');
var RFC1123 = require('../../../util/rfc1123date');

var Constants = require('../../../util/constants');
var ServiceBusConstants = Constants.ServiceBusConstants;
var HeaderConstants = Constants.HeaderConstants;

// Expose 'QueueMessageResult'.
exports = module.exports = QueueMessageResult;

function QueueMessageResult() { }

QueueMessageResult.parse = function (responseObject) {
  var queueMessageResult = new QueueMessageResult();

  queueMessageResult.messagetext = responseObject.body;

  if (responseObject.headers[HeaderConstants.BROKER_PROPERTIES_HEADER]) {
    queueMessageResult.brokerProperties = {};

    var brokerProperties = JSON.parse(responseObject.headers[HeaderConstants.BROKER_PROPERTIES_HEADER]);
    for (var property in brokerProperties) {
      queueMessageResult.brokerProperties[property] = brokerProperties[property];
    }
  }

  // Process custom properties
  var customProperties = null;
  for (var header in responseObject.headers) {
    // Excluded known standard response headers
    if (header !== HeaderConstants.CONTENT_TYPE &&
        header !== HeaderConstants.BROKER_PROPERTIES_HEADER &&
        header !== HeaderConstants.TRANSFER_ENCODING_HEADER &&
        header !== HeaderConstants.SERVER_HEADER &&
        header !== HeaderConstants.DATE) {

      // Assume custom property
      if (!customProperties) {
        customProperties = {};
      }

      customProperties[header] = QueueMessageResult._propertyFromString(responseObject.headers[header]);
    }
  }

  if (customProperties) {
    queueMessageResult.customProperties = customProperties;
  }

  return queueMessageResult;
};

QueueMessageResult._propertyFromString = function (value) {
  if (value === null) {
    return null;
  }

  if (azureutil.stringStartsWith(value, "\"") && azureutil.stringEndsWith(value, "\"")) {
    var text = value.substr(1, value.length - 2);
    if (QueueMessageResult.isRFC1123(text)) {
      return RFC1123.parse(text);
    }

    return text;
  } else if (value === 'true') {
    return true;
  } else if (value === 'false') {
    return false;
  } else if (azureutil.isInt(value)) {
    return parseInt(value);
  } else {
    return parseFloat(value);
  }
};

QueueMessageResult.isRFC1123 = function (value) {
  var date = new Date(value);
  return azureutil.isValidDate(date);
};<commit_msg>Adding missing queuemessageresult headers.<commit_after>/**
* Copyright 2011 Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Module dependencies.
var util = require('util');

var azureutil = require('../../../util/util');
var RFC1123 = require('../../../util/rfc1123date');

var Constants = require('../../../util/constants');
var ServiceBusConstants = Constants.ServiceBusConstants;
var HeaderConstants = Constants.HeaderConstants;

// Expose 'QueueMessageResult'.
exports = module.exports = QueueMessageResult;

function QueueMessageResult() { }

QueueMessageResult.parse = function (responseObject) {
  var queueMessageResult = new QueueMessageResult();

  queueMessageResult.messagetext = responseObject.body;

  if (responseObject.headers[HeaderConstants.BROKER_PROPERTIES_HEADER]) {
    queueMessageResult.brokerProperties = {};

    var brokerProperties = JSON.parse(responseObject.headers[HeaderConstants.BROKER_PROPERTIES_HEADER]);
    for (var property in brokerProperties) {
      queueMessageResult.brokerProperties[property] = brokerProperties[property];
    }
  }

  // Process custom properties
  var customProperties = null;
  for (var header in responseObject.headers) {
    // Excluded known standard response headers
    if (header !== HeaderConstants.CONTENT_TYPE &&
        header !== HeaderConstants.BROKER_PROPERTIES_HEADER &&
        header !== HeaderConstants.TRANSFER_ENCODING_HEADER &&
        header !== HeaderConstants.SERVER_HEADER &&
        header !== HeaderConstants.LOCATION_HEADER &&
        header !== HeaderConstants.DATE) {

      // Assume custom property
      if (!customProperties) {
        customProperties = {};
      }

      customProperties[header] = QueueMessageResult._propertyFromString(responseObject.headers[header]);
    }
  }

  if (responseObject.headers[HeaderConstants.LOCATION_HEADER]) {
    queueMessageResult.location = responseObject.headers[HeaderConstants.LOCATION_HEADER];
  }

  if (responseObject.headers[HeaderConstants.CONTENT_TYPE]) {
    queueMessageResult.contentType = responseObject.headers[HeaderConstants.CONTENT_TYPE];
  }

  if (customProperties) {
    queueMessageResult.customProperties = customProperties;
  }

  return queueMessageResult;
};

QueueMessageResult._propertyFromString = function (value) {
  if (value === null) {
    return null;
  }

  if (azureutil.stringStartsWith(value, "\"") && azureutil.stringEndsWith(value, "\"")) {
    var text = value.substr(1, value.length - 2);
    if (QueueMessageResult.isRFC1123(text)) {
      return RFC1123.parse(text);
    }

    return text;
  } else if (value === 'true') {
    return true;
  } else if (value === 'false') {
    return false;
  } else if (azureutil.isInt(value)) {
    return parseInt(value);
  } else {
    return parseFloat(value);
  }
};

QueueMessageResult.isRFC1123 = function (value) {
  var date = new Date(value);
  return azureutil.isValidDate(date);
};<|endoftext|>


<commit_before>/*
 * Copyright (c) 2013 Csernik Flaviu Andrei
 *
 * See the file LICENSE.txt for copying permission.
 *
 */

/*jslint browser: true, bitwise: true, es5: true, indent: 2 nomen: true*/

(function (global) {

  "use strict";

  var twoPI = 2 * Math.PI;

  function windowHann(i, length) {

    return 0.5 * (1 - Math.cos(twoPI * i / (length - 1)));

  }

  function windowHamming(i, length) {

    return 0.54 - 0.46 * Math.cos(twoPI * i / (length - 1));

  }

  function selectWindowFunctionType(type) {

    switch (type) {
    case "Hamming":
      return windowHamming;
    case "Hann":
      return windowHann;
    case undefined:
      throw new ReferenceError("No window function type selected.");
    default:
      throw new ReferenceError("Unknown window function " + type);
    }
  }

  function WindowFunction() {

    var _type
      , _length
      , values
      , windowFunction
      ;

    Object.defineProperties(this, {
        "type" : {
            enumerable   : true
          , configurable : false
          , get : function () {
              return _type;
          }
          , set : function (tp) {

              var i;

              _type = tp;
              windowFunction = selectWindowFunctionType(tp);

              if (_length) {
                for (i = 0; i < _length; i += 1) {
                  values[i] = windowFunction(i, _length);
                }
              }
          }
      }
      , "length" : {
            enumerable   : true
          , configurable : false
          , get : function () {
              return _length;
            }
          , set : function (value) {

              var i;

              _length = value;
              values  = new Float32Array(_length);

              if (_type) {
                for (i = 0; i < _length; i += 1) {
                  values[i] = windowFunction(i, _length);
                }
              }
         }
      }
    });

    Object.defineProperty(WindowFunction.prototype, "process", {
        value : function (buffer) {

          if (buffer.length !== _length) {
            throw new TypeError("Given buffer is not the same length as" +
                                " the length property of WindowFunction." +
                                "\nExpected : " + _length +
                                "\nGiven    : " + buffer.length
                                );
          }

          buffer.map(function (v, i) { return v * values[i]; });

      }
      , enumerable   : true
      , configurable : false
      , writable     : false
    });
  }

  global.WindowObject = WindowFunction;

}(window));<commit_msg>Check WindowFunction property initialization.<commit_after>/*
 * Copyright (c) 2013 Csernik Flaviu Andrei
 *
 * See the file LICENSE.txt for copying permission.
 *
 */

/*jslint browser: true, bitwise: true, es5: true, indent: 2 nomen: true*/

(function (global) {

  "use strict";

  function PropertyNotInitialized(propName) {
    this.property = propName;
  }

  PropertyNotInitialized.prototype.toString = function () {
        return "Property " + this.property + " not initialized.";
  };

  var twoPI = 2 * Math.PI;

  function windowHann(i, length) {

    return 0.5 * (1 - Math.cos(twoPI * i / (length - 1)));

  }

  function windowHamming(i, length) {

    return 0.54 - 0.46 * Math.cos(twoPI * i / (length - 1));

  }

  function selectWindowFunctionType(type) {

    switch (type) {
    case "Hamming":
      return windowHamming;
    case "Hann":
      return windowHann;
    case undefined:
      throw new ReferenceError("No window function type selected.");
    default:
      throw new ReferenceError("Unknown window function " + type);
    }
  }

  function WindowFunction() {

    var _type
      , _length
      , values
      , windowFunction
      ;

    Object.defineProperties(this, {
        "type" : {
            enumerable   : true
          , configurable : false
          , get : function () {

              if (!_type) {
                throw new PropertyNotInitialized("type");
              }

              return _type;
          }
          , set : function (tp) {

              var i;

              _type = tp;
              windowFunction = selectWindowFunctionType(tp);

              if (_length) {
                for (i = 0; i < _length; i += 1) {
                  values[i] = windowFunction(i, _length);
                }
              } else {
                throw new PropertyNotInitialized("length");
              }
          }
      }
      , "length" : {
            enumerable   : true
          , configurable : false
          , get : function () {

              if (!_length) {
                throw new PropertyNotInitialized("length");
              }

              return _length;
            }
          , set : function (value) {

              var i;

              _length = value;
              values  = new Float32Array(_length);

              if (_type) {
                for (i = 0; i < _length; i += 1) {
                  values[i] = windowFunction(i, _length);
                }
              } else {
                throw new PropertyNotInitialized("type");
              }
         }
      }
    });

    Object.defineProperty(WindowFunction.prototype, "process", {
        value : function (buffer) {

          if (!_length && !_type) {
            throw new PropertyNotInitialized("length and type");
          }

          if (buffer.length !== _length) {
            throw new TypeError("Given buffer is not the same length as" +
                                " the length property of WindowFunction." +
                                "\nExpected : " + _length +
                                "\nGiven    : " + buffer.length
                                );
          }

          buffer.map(function (v, i) { return v * values[i]; });

      }
      , enumerable   : true
      , configurable : false
      , writable     : false
    });
  }

  global.WindowObject = WindowFunction;

}(window));<|endoftext|>


<commit_before>exports.productionVersionId = "e14316df4c4a";<commit_msg>Incrementing Production Version.<commit_after>exports.productionVersionId = "dccbe6f73642";<|endoftext|>


<commit_before>test(
  'ObjEachTest',

  [
    'ephox.katamari.api.Obj'
  ],

  function (Obj) {
    var check = function (expected, C, input) {
      var values = [];
      Obj.each(input, function (x, i) {
        values.push({index: i, value: x});
      });
      assert.eq(expected, values);
    };

    var checkO = function (expected, input) {
      check(expected, input);
    };

    checkO([], {});
    checkO([{index: 'a', value: 'A'}], {a: 'A'});
    checkO([{index: 'a', value: 'A'}, {index: 'b', value: 'B'}, {index: 'c', value: 'C'}], {a: 'A', b: 'B', c: 'C'});
  }
);
<commit_msg>VAN-29: all tests passing again<commit_after>test(
  'ObjEachTest',

  [
    'ephox.katamari.api.Obj'
  ],

  function (Obj) {
    var check = function (expected, input) {
      var values = [];
      Obj.each(input, function (x, i) {
        values.push({index: i, value: x});
      });
      assert.eq(expected, values);
    };

    var checkO = function (expected, input) {
      check(expected, input);
    };

    checkO([], {});
    checkO([{index: 'a', value: 'A'}], {a: 'A'});
    checkO([{index: 'a', value: 'A'}, {index: 'b', value: 'B'}, {index: 'c', value: 'C'}], {a: 'A', b: 'B', c: 'C'});
  }
);
<|endoftext|>


<commit_before>module.exports = function transformRpMessage(str, color) {
  // how to render a specific type of tag
  var renderTag = {
    'ACTION': {
      open: function(color) {
        var contrast = color ? (tinycolor(color).isLight() ? 'black' : 'white') : 'auto';
        return '*';
      },
      close: '*'
    },
    'BOLD': { open: function() { return '' }, close: '' },
    'ITC': { open: function() { return '' }, close: '' },
    'BOLDITC': { open: function() { return '' }, close: '' },
    'STRIKE': { open: function() { return '' }, close: '' },
  };

  // tokens that create tags
  var tagLexers = [
    { r: /^https?:\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]/i, replace: function(link) { return ''+link+''; } },
    { r: /^____/ }, // if there's a lot of _, don't treat it as anything
    { r: /^___/, tag: 'BOLDITC' },
    { r: /^__/, tag: 'BOLD' },
    { r: /^_/, tag: 'ITC' },
    { r: /^\//, tag: 'ITC' },
    { r: /^~~/, tag: 'STRIKE' },
    { r: /^\*/, tag: 'ACTION' },
    { r: /^(?:\r\n|\n\r|\r|\n)/, replaceWith: '
' },
    { r: /^--/, replaceWith: '—' },
    { r: /^\s/ },
    { r: /^\S/, replace: function(str) { return str.replace(/[&<>"']/g, function (char) { return ({'&':'&','<':'<','>':'>','"':'"',"'":'''})[char]; }); } },
  ];

  // processed tokens
  var tokens = [];
  // currently open tags on a stack
  var tagTokenStack = [];

  // iterate through the string...
  while (str.length > 0) {
    var match;
    var tag;
    var replace;
    var replaceWith;

    // see if the front of the string matches any token types
    for (var i = 0; i < tagLexers.length; ++i) {
      var tagLexer = tagLexers[i];
      var result = tagLexer.r.exec(str);
      if (result) {
        match = result[0];
        replace = tagLexer.replace;
        replaceWith = tagLexer.replaceWith;
        tag = tagLexer.tag;
        break;
      }
    }

    // determine what to do with what we got from the front of the string
    if (tag) {
      // if it's an open/close tag, do some stack logic with it
      var opener = tagTokenStack.filter(function(t) { return t.match === match; })[0];
      var openerStackIdx = tagTokenStack.indexOf(opener);
      if (openerStackIdx >= 0) {
        // closing tag found!
        // discard all tags atop this one
        tagTokenStack.slice(openerStackIdx + 1).forEach(function(t) {
          var idx = tokens.indexOf(t);
          tokens[idx] = t.match;
        });
        // apply both tags
        tokens[tokens.indexOf(opener)] = renderTag[tag].open(color);
        tokens.push(renderTag[tag].close);
        // pop stack
        tagTokenStack = tagTokenStack.slice(0, openerStackIdx);
      } else if (tagTokenStack.filter(function(t) { return t.tag === tag })[0]) {
        // same tag, but different syntax? = ignore it
        // example: "this should /not_ be italics"
        tokens.push(match);
      } else {
        // opening tags
        var token = { tag: tag, match: match };
        tokens.push(token);
        tagTokenStack.push(token);
      }
    } else if (replace) {
      // replace text using a function
      tokens.push(replace(match));
    } else if (replaceWith) {
      // replace text with a string
      tokens.push(replaceWith);
    } else if (match) {
      // just add it as is
      tokens.push(match);
    } else {
      throw new Error('Could not match ' + str[0]);
    }

    // cut off the processed part of the string
    str = str.substr(match.length);
  }

  // discard remaining open tags
  tagTokenStack.forEach(function(t) {
    var idx = tokens.indexOf(t);
    tokens[idx] = t.match;
  });

  return tokens.join('');
};
<commit_msg>Fix issue where a message is surrounded by five underscores<commit_after>module.exports = function transformRpMessage(str, color) {
  // how to render a specific type of tag
  var renderTag = {
    'ACTION': {
      open: function(color) {
        var contrast = color ? (tinycolor(color).isLight() ? 'black' : 'white') : 'auto';
        return '*';
      },
      close: '*'
    },
    'BOLD': { open: function() { return '' }, close: '' },
    'ITC': { open: function() { return '' }, close: '' },
    'BOLDITC': { open: function() { return '' }, close: '' },
    'STRIKE': { open: function() { return '' }, close: '' },
  };

  // tokens that create tags
  var tagLexers = [
    { r: /^https?:\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]/i, replace: function(link) { return ''+link+''; } },
    { r: /^____+/ }, // if there's a lot of _, don't treat it as anything
    { r: /^___/, tag: 'BOLDITC' },
    { r: /^__/, tag: 'BOLD' },
    { r: /^_/, tag: 'ITC' },
    { r: /^\//, tag: 'ITC' },
    { r: /^~~/, tag: 'STRIKE' },
    { r: /^\*/, tag: 'ACTION' },
    { r: /^(?:\r\n|\n\r|\r|\n)/, replaceWith: '
' },
    { r: /^--/, replaceWith: '—' },
    { r: /^\s/ },
    { r: /^\S/, replace: function(str) { return str.replace(/[&<>"']/g, function (char) { return ({'&':'&','<':'<','>':'>','"':'"',"'":'''})[char]; }); } },
  ];

  // processed tokens
  var tokens = [];
  // currently open tags on a stack
  var tagTokenStack = [];

  // iterate through the string...
  while (str.length > 0) {
    var match;
    var tag;
    var replace;
    var replaceWith;

    // see if the front of the string matches any token types
    for (var i = 0; i < tagLexers.length; ++i) {
      var tagLexer = tagLexers[i];
      var result = tagLexer.r.exec(str);
      if (result) {
        match = result[0];
        replace = tagLexer.replace;
        replaceWith = tagLexer.replaceWith;
        tag = tagLexer.tag;
        break;
      }
    }

    // determine what to do with what we got from the front of the string
    if (tag) {
      // if it's an open/close tag, do some stack logic with it
      var opener = tagTokenStack.filter(function(t) { return t.match === match; })[0];
      var openerStackIdx = tagTokenStack.indexOf(opener);
      if (openerStackIdx >= 0) {
        // closing tag found!
        // discard all tags atop this one
        tagTokenStack.slice(openerStackIdx + 1).forEach(function(t) {
          var idx = tokens.indexOf(t);
          tokens[idx] = t.match;
        });
        // apply both tags
        tokens[tokens.indexOf(opener)] = renderTag[tag].open(color);
        tokens.push(renderTag[tag].close);
        // pop stack
        tagTokenStack = tagTokenStack.slice(0, openerStackIdx);
      } else if (tagTokenStack.filter(function(t) { return t.tag === tag })[0]) {
        // same tag, but different syntax? = ignore it
        // example: "this should /not_ be italics"
        tokens.push(match);
      } else {
        // opening tags
        var token = { tag: tag, match: match };
        tokens.push(token);
        tagTokenStack.push(token);
      }
    } else if (replace) {
      // replace text using a function
      tokens.push(replace(match));
    } else if (replaceWith) {
      // replace text with a string
      tokens.push(replaceWith);
    } else if (match) {
      // just add it as is
      tokens.push(match);
    } else {
      throw new Error('Could not match ' + str[0]);
    }

    // cut off the processed part of the string
    str = str.substr(match.length);
  }

  // discard remaining open tags
  tagTokenStack.forEach(function(t) {
    var idx = tokens.indexOf(t);
    tokens[idx] = t.match;
  });

  return tokens.join('');
};
<|endoftext|>


<commit_before>'use strict';

import {defaultDataPathBaseUrl} from '../../../js/config.js';

export var config = {
  dataPaths: {
    wildfiresList: defaultDataPathBaseUrl + '/MTBS/MTBSSampled.json',
    wildfiresFireKmz: defaultDataPathBaseUrl + '/MTBS/kmz/'
  }
}
<commit_msg>Cleanup config<commit_after>'use strict';

import {defaultDataPathBaseUrl} from '../../../js/config.js';

export var config = {
  dataPaths: {
    wildfiresList: defaultDataPathBaseUrl + '/MTBS/MTBS.json',
    wildfiresFireKmz: defaultDataPathBaseUrl + '/MTBS/kmz/'
  }
}
<|endoftext|>


<commit_before>jQuery(document).ready(function($) {

	$('#create_nc_model').click(function(e){
		e.preventDefault();
		// make sure folder name is not empty and also the folder with same name exists
		var model_name = $('#create_model_pname').val();
		var owner=$('#dragoon_ncCModel_form input[name=u]').val();
		console.log("form check parameters", model_name, owner);
		checkValidity(model_name,owner);
	});

	function checkValidity(model_name,owner){
		//empty case
		if(model_name == ''){
			//
			console.log("problem name is empty");
			$('#create_model_pname').addClass('focusedtextselect');
			$('#create_model_pname').attr("placeholder","Model Name can not be empty");
			return;
		}

		//duplicate model case
		var existing_models=$('#dragoon_ncCModel_form input[name=z]').val();
		var folder_name = $('#create_model_folder_name').val().split("-");
		if(folder_name[1] != "private")
			folder_name = folder_name[0];
		else
			folder_name = "private";

		//console.log("existing models",existing_models,folder_name,model_name);
		var toCheck=JSON.parse(existing_models);
		if(folder_name != ""){
			$.each(toCheck.private,function(key,val){
				console.log(key,val,model_name,typeof val)
				if(typeof val == "string" &&  key == model_name){
					reportDupModels(model_name);
					return;
				}
				else if(typeof val == "object"){
					$.each(val,function(mname,mvalue){
						if(typeof mvalue == "string" && mname == model_name){
							reportDupModels(model_name);
						}
					});
				}
			});
		}
		console.log("creating Model");
		createModel();
	}

	var createModel = function(){
		var form = document.forms['dragoon_ncCModel_form'];
		$('#create_model_pname').removeClass("focusedtextselect");
		$('#createModelModal').modal('hide');
		var url = $("#dragoon_url").val()+"index.php";
		form.setAttribute("action", url);
		form.setAttribute("target", "_blank");
		form.setAttribute("method", "POST");
		form["g"].value = $('#create_model_folder_name').val();
		form["f"].value = form["g"].value;
		form.submit();
		setTimeout(function(){
			location.reload();
		},2000);
	}

	var reportDupModels = function(model_name){
		console.log("problem name is duplicate");
		$('#create_model_pname').addClass('focusedtextselect');
		$('#create_model_pname').val('');
		$('#create_model_pname').attr("placeholder",model_name+" already exists");
		throw new duplicateModelException("duplicate model");

	}

	function duplicateModelException(message) {
		this.message = message;
		this.name = "UserException";
	}
});
<commit_msg>emptying form parameter z before form submit as this is just used for checking model duplication but needed for form submit<commit_after>jQuery(document).ready(function($) {

	$('#create_nc_model').click(function(e){
		e.preventDefault();
		// make sure folder name is not empty and also the folder with same name exists
		var model_name = $('#create_model_pname').val();
		var owner=$('#dragoon_ncCModel_form input[name=u]').val();
		console.log("form check parameters", model_name, owner);
		checkValidity(model_name,owner);
	});

	function checkValidity(model_name,owner){
		//empty case
		if(model_name == ''){
			//
			console.log("problem name is empty");
			$('#create_model_pname').addClass('focusedtextselect');
			$('#create_model_pname').attr("placeholder","Model Name can not be empty");
			return;
		}

		//duplicate model case
		var existing_models=$('#dragoon_ncCModel_form input[name=z]').val();
		var folder_name = $('#create_model_folder_name').val().split("-");
		if(folder_name[1] != "private")
			folder_name = folder_name[0];
		else
			folder_name = "private";

		//console.log("existing models",existing_models,folder_name,model_name);
		var toCheck=JSON.parse(existing_models);
		if(folder_name != ""){
			$.each(toCheck.private,function(key,val){
				console.log(key,val,model_name,typeof val)
				if(typeof val == "string" &&  key == model_name){
					reportDupModels(model_name);
					return;
				}
				else if(typeof val == "object"){
					$.each(val,function(mname,mvalue){
						if(typeof mvalue == "string" && mname == model_name){
							reportDupModels(model_name);
						}
					});
				}
			});
		}
		console.log("creating Model");
		createModel();
	}

	var createModel = function(){
		var form = document.forms['dragoon_ncCModel_form'];
		$('#create_model_pname').removeClass("focusedtextselect");
		$('#createModelModal').modal('hide');
		var url = $("#dragoon_url").val()+"index.php";
		form.setAttribute("action", url);
		form.setAttribute("target", "_blank");
		form.setAttribute("method", "POST");
		form["g"].value = $('#create_model_folder_name').val();
		form["f"].value = form["g"].value;
		form["z"].value = "";
		form.submit();
		setTimeout(function(){
			location.reload();
		},2000);
	}

	var reportDupModels = function(model_name){
		console.log("problem name is duplicate");
		$('#create_model_pname').addClass('focusedtextselect');
		$('#create_model_pname').val('');
		$('#create_model_pname').attr("placeholder",model_name+" already exists");
		throw new duplicateModelException("duplicate model");

	}

	function duplicateModelException(message) {
		this.message = message;
		this.name = "UserException";
	}
});
<|endoftext|>


<commit_before>export default function (opts) {
  let callback = opts.attribute || function () {};
  return function (name, oldValue, newValue) {
    callback(this, {
      name: name,
      newValue: newValue === null ? undefined : newValue,
      oldValue: oldValue === null ? undefined : oldValue
    });
  };
}
<commit_msg>perf: early exit in case we did not get a callback<commit_after>const noop = () => {};

export default function (opts) {
  let callback = opts.attribute;

  if (typeof callback !== 'function') {
    return noop;
  }

  return function (name, oldValue, newValue) {
    callback(this, {
      name: name,
      newValue: newValue === null ? undefined : newValue,
      oldValue: oldValue === null ? undefined : oldValue
    });
  };
}
<|endoftext|>


<commit_before>var express    = require('express');
var app        = express();
var bodyParser = require('body-parser');
var request = require('request');
var _ = require('underscore');
var constants = require('bastly_constants');
var program = require('commander');

program
  .version('0.0.1')
  .usage('connector-rest --atahualpa <IP> --orion <IP:port> --callback <IP:port>')
  .option('-a, --atahualpa <IP>', 'specify atahualpa IP to connect to', '127.0.0.1')
  .option('-o, --orion <IP:port>', 'specify orion IP and PORT to connect to', '127.0.0.1:1026')
  .option('-c, --callback <IP:port>', 'specify the callback ip of this endpoint', '127.0.0.1:8080')
  .parse(process.argv);

console.log('Running with atahualpa on: ', program.atahualpa);
console.log('Running with orion on: ', program.orion);
console.log('Running with callback ip on: ', program.callback);

//allows CORS for everywhere
var allowCrossDomain = function(req, res, next) {
    res.header('Access-Control-Allow-Credentials', true);
    res.header('Access-Control-Allow-Origin', req.headers.origin);
    res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
    res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With, Origin, Accept');
    next();
};

app.use(allowCrossDomain);

var IP_ORION = program.orion;
var IP_ATAHUALPA = program.atahualpa;
var IP_CALLBACK = program.callback;
//var bastly = require('bastly')({ipAtahualpa:IP_ATAHUALPA});
var bastly = require('../sdk-node')({ipAtahualpa:IP_ATAHUALPA});

// this will let us get the data from a POST
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

var port = process.env.PORT || 8080;        // set our port
var subscriptions = {};

console.log('Listenint to port: ', port);

// ROUTES FOR OUR API
// =============================================================================
var router = express.Router();              // get an instance of the express Router

// chaski worker request
router.get('/requestChaski', function(req, res) {
    var channel = req.param('channel');
    var chaskiType = req.param('chaskiType');
    if(!channel){
        res.json({ message: "must specify ?channel="  });
        return;
    }
    if(!chaskiType){
        res.json({ message: "must specify ?chaskiType=" + constants.CHASKI_TYPE_SOCKETIO + '/' + constants.CHASKI_TYPE_ZEROMQ });
        return;
    }
    bastly.getWorker(channel, chaskiType, function(reply){
        console.log('got reply from get worker: ' + reply);
        res.json({ message: reply  });
    });
});

router.post('/subscribtionObjectStructure', function (req, res){ //551c09c9984d23677ebc3cff
    // console.log('object structure watcher');

    _.each(req.body.contextResponses, function (elem) {

        // console.log(elem.contextElement);
        var attrs = [];
        _.each( elem.contextElement.attributes, function (attribute){
            attrs.push(attribute.name);
        });

        if ( subscriptions[elem.contextElement.id]  === undefined || subscriptions[elem.contextElement.id] === null){

            console.log('create subscription');
            request.post({
                url: 'http://' + IP_ORION + '/v1/subscribeContext',
                json: true,
                body: {
                    "entities": [
                    {
                        "type": "BastlyMSG",
                        "isPattern": "false",
                        "id": elem.contextElement.id
                    }
                    ],
                    "attributes": [],
                    "reference": "http://" + IP_CALLBACK + "/api/subscription",
                    "duration": "P1M",
                    "notifyConditions": [
                    {
                        "type": "ONCHANGE",
                        "condValues": attrs
                    }
                    ],
                    "throttling": "PT1S"
                }
            },
            function (error, response, body) {
                console.log(body);
                subscriptions[elem.contextElement.id] = {subscriptionId : body.subscribeResponse.subscriptionId, attributes : attrs};
            });

        } else { // only update subscription if any attrs has change cause it generates a notification.
            if (_.difference(attrs, subscriptions[elem.contextElement.id].attributes).length > 0) {
                console.log('arrays differ');
                console.log('update subscription ', subscriptions[elem.contextElement.id].subscriptionId);

                request.post({
                    url: 'http://' + IP_ORION + '/v1/updateContextSubscription',
                    json: true,
                    body: {
                        "subscriptionId": subscriptions[elem.contextElement.id].subscriptionId,
                        "notifyConditions": [
                        {
                            "type": "ONCHANGE",
                            "condValues": attrs
                        }
                        ]
                    }
                },
                function (error, response, body) {
                    // console.log(body);
                    subscriptions[elem.contextElement.id].subscriptionId = body.subscribeResponse.subscriptionId;
                    subscriptions[elem.contextElement.id].attributes = attrs;
                });
            }  else {
                console.log('arrays do not differ', _.difference(attrs, subscriptions[elem.contextElement.id].attributes));
            }
        }

    });

    res.sendStatus(200);
});

router.post('/subscription', function (req, res) {
    var updatedElement = req.body.contextResponses[0].contextElement;
    var channels = [];
    if (_.findLastIndex(updatedElement.attributes, { name: 'channels' }) != -1) {
        channels = updatedElement.attributes[_.findLastIndex(updatedElement.attributes, { name: 'channels' })].value;
    }

    var apiKey = updatedElement.id.substring("BastlyKey:".length, updatedElement.id.indexOf(":userId:"));
    console.log('Object data updated: ', updatedElement);

    _.each(channels, function (channel) {
        //TODO verify apikey, from is ORION?
        bastly.sendMessage(channel, "ORION", apiKey,  updatedElement, function(reply){
            console.log('messasge ack!', reply);
        });
    });

    res.sendStatus(200);
});

// message publisher
router.post('/publishMessage', function(req, res) {
    var data = JSON.parse(req.body.data);
    var from = req.body.from;
    var to = req.body.to;
    var apiKey = req.body.apiKey;
    bastly.sendMessage(to, from, apiKey, data, function(repply){
        console.log('messasge ack!');
        res.json({ message: 'ok' });
    });
});

// REGISTER OUR ROUTES -------------------------------
// all of our routes will be prefixed with /api
app.use('/api', router);

// START THE SERVER
// =============================================================================
app.listen(port);

// Register to all changes in structures in ORION each 30 secs
request.post({
    url: 'http://' + IP_ORION + '/v1/subscribeContext',
    json: true,
    body: {
        "entities": [
            {
                "type": "BastlyMSG",
                "isPattern": "true",
                "id": "BastlyKey:*"
            }
        ],
        "attributes": [],
        "reference": "http://" + IP_CALLBACK + "/api/subscribtionObjectStructure",
        "duration": "P1M",
        "notifyConditions": [
            {
                "type": "ONTIMEINTERVAL",
                "condValues": [
                    "PT30S"
                ]
            }
        ]
    }
},
function (error, response, body) {
    console.log(body);
});
<commit_msg>added some more detailed loggin<commit_after>var express    = require('express');
var app        = express();
var bodyParser = require('body-parser');
var request = require('request');
var _ = require('underscore');
var constants = require('bastly_constants');
var program = require('commander');

program
  .version('0.0.1')
  .usage('connector-rest --atahualpa <IP> --orion <IP:port> --callback <IP:port>')
  .option('-a, --atahualpa <IP>', 'specify atahualpa IP to connect to', '127.0.0.1')
  .option('-o, --orion <IP:port>', 'specify orion IP and PORT to connect to', '127.0.0.1:1026')
  .option('-c, --callback <IP:port>', 'specify the callback ip of this endpoint', '127.0.0.1:8080')
  .parse(process.argv);

console.log('Running with atahualpa on: ', program.atahualpa);
console.log('Running with orion on: ', program.orion);
console.log('Running with callback ip on: ', program.callback);

//allows CORS for everywhere
var allowCrossDomain = function(req, res, next) {
    res.header('Access-Control-Allow-Credentials', true);
    res.header('Access-Control-Allow-Origin', req.headers.origin);
    res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
    res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With, Origin, Accept');
    next();
};

app.use(allowCrossDomain);

var IP_ORION = program.orion;
var IP_ATAHUALPA = program.atahualpa;
var IP_CALLBACK = program.callback;
//var bastly = require('bastly')({ipAtahualpa:IP_ATAHUALPA});
var bastly = require('../sdk-node')({ipAtahualpa:IP_ATAHUALPA});

// this will let us get the data from a POST
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

var port = process.env.PORT || 8080;        // set our port
var subscriptions = {};

console.log('Listenint to port: ', port);

// ROUTES FOR OUR API
// =============================================================================
var router = express.Router();              // get an instance of the express Router

// chaski worker request
router.get('/requestChaski', function(req, res) {
    var channel = req.param('channel');
    var chaskiType = req.param('chaskiType');
    console.log('requesting chaski', channel, chaskiType);
    if(!channel){
        res.json({ message: "must specify ?channel="  });
        return;
    }
    if(!chaskiType){
        res.json({ message: "must specify ?chaskiType=" + constants.CHASKI_TYPE_SOCKETIO + '/' + constants.CHASKI_TYPE_ZEROMQ });
        return;
    }
    bastly.getWorker(channel, chaskiType, function(reply){
        console.log('got reply from get worker: ' + reply);
        res.json({ message: reply  });
    });
});

router.post('/subscribtionObjectStructure', function (req, res){ //551c09c9984d23677ebc3cff
    // console.log('object structure watcher');

    _.each(req.body.contextResponses, function (elem) {

        // console.log(elem.contextElement);
        var attrs = [];
        _.each( elem.contextElement.attributes, function (attribute){
            attrs.push(attribute.name);
        });

        if ( subscriptions[elem.contextElement.id]  === undefined || subscriptions[elem.contextElement.id] === null){

            console.log('create subscription');
            request.post({
                url: 'http://' + IP_ORION + '/v1/subscribeContext',
                json: true,
                body: {
                    "entities": [
                    {
                        "type": "BastlyMSG",
                        "isPattern": "false",
                        "id": elem.contextElement.id
                    }
                    ],
                    "attributes": [],
                    "reference": "http://" + IP_CALLBACK + "/api/subscription",
                    "duration": "P1M",
                    "notifyConditions": [
                    {
                        "type": "ONCHANGE",
                        "condValues": attrs
                    }
                    ],
                    "throttling": "PT1S"
                }
            },
            function (error, response, body) {
                console.log('body', body);
                subscriptions[elem.contextElement.id] = {subscriptionId : body.subscribeResponse.subscriptionId, attributes : attrs};
            });

        } else { // only update subscription if any attrs has change cause it generates a notification.
            if (_.difference(attrs, subscriptions[elem.contextElement.id].attributes).length > 0) {
                console.log('arrays differ');
                console.log('update subscription ', subscriptions[elem.contextElement.id].subscriptionId);

                request.post({
                    url: 'http://' + IP_ORION + '/v1/updateContextSubscription',
                    json: true,
                    body: {
                        "subscriptionId": subscriptions[elem.contextElement.id].subscriptionId,
                        "notifyConditions": [
                        {
                            "type": "ONCHANGE",
                            "condValues": attrs
                        }
                        ]
                    }
                },
                function (error, response, body) {
                    // console.log(body);
                    subscriptions[elem.contextElement.id].subscriptionId = body.subscribeResponse.subscriptionId;
                    subscriptions[elem.contextElement.id].attributes = attrs;
                });
            }  else {
                console.log('arrays do not differ', _.difference(attrs, subscriptions[elem.contextElement.id].attributes));
            }
        }

    });

    res.sendStatus(200);
});

router.post('/subscription', function (req, res) {
    var updatedElement = req.body.contextResponses[0].contextElement;
    var channels = [];
    if (_.findLastIndex(updatedElement.attributes, { name: 'channels' }) != -1) {
        channels = updatedElement.attributes[_.findLastIndex(updatedElement.attributes, { name: 'channels' })].value;
    }

    var apiKey = updatedElement.id.substring("BastlyKey:".length, updatedElement.id.indexOf(":userId:"));
    console.log('Object data updated: ', updatedElement);

    _.each(channels, function (channel) {
        //TODO verify apikey, from is ORION?
        bastly.sendMessage(channel, "ORION", apiKey,  updatedElement, function(reply){
            console.log('messasge ack!', reply);
        });
    });

    res.sendStatus(200);
});

// message publisher
router.post('/publishMessage', function(req, res) {
    var data = JSON.parse(req.body.data);
    var from = req.body.from;
    var to = req.body.to;
    var apiKey = req.body.apiKey;
    bastly.sendMessage(to, from, apiKey, data, function(repply){
        console.log('messasge ack!');
        res.json({ message: 'ok' });
    });
});

// REGISTER OUR ROUTES -------------------------------
// all of our routes will be prefixed with /api
app.use('/api', router);

// START THE SERVER
// =============================================================================
app.listen(port);

// Register to all changes in structures in ORION each 30 secs
request.post({
    url: 'http://' + IP_ORION + '/v1/subscribeContext',
    json: true,
    body: {
        "entities": [
            {
                "type": "BastlyMSG",
                "isPattern": "true",
                "id": "BastlyKey:*"
            }
        ],
        "attributes": [],
        "reference": "http://" + IP_CALLBACK + "/api/subscribtionObjectStructure",
        "duration": "P1M",
        "notifyConditions": [
            {
                "type": "ONTIMEINTERVAL",
                "condValues": [
                    "PT30S"
                ]
            }
        ]
    }
},
function (error, response, body) {
    console.log('body 2', body);
});
<|endoftext|>


<commit_before>'use strict';

$(function() {

	// Helper function for vertically aligning DOM elements
	// http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/
	$.fn.vAlign = function() {
		return this.each(function(){
			var ah = $(this).height();
			var ph = $(this).parent().height();
			var mh = (ph - ah) / 2;
			$(this).css('margin-top', mh);
		});
	};

	$.fn.stretchFormtasticInputWidthToParent = function() {
		return this.each(function(){
			var p_width = $(this).closest("form").innerWidth();
			var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest('form').css('padding-right'), 10);
			var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10);
			$(this).css('width', p_width - p_padding - this_padding);
		});
	};

	$('form.formtastic li.string input, form.formtastic textarea').stretchFormtasticInputWidthToParent();

	// Vertically center these paragraphs
	// Parent may need a min-height for this to work..
	$('ul.downplayed li div.content p').vAlign();

	// When a sandbox form is submitted..
	$("form.sandbox").submit(function(){

		var error_free = true;

		// Cycle through the forms required inputs
 		$(this).find("input.required").each(function() {

			// Remove any existing error styles from the input
			$(this).removeClass('error');

			// Tack the error style on if the input is empty..
			if ($(this).val() === '') {
				$(this).addClass('error');
				$(this).wiggle();
				error_free = false;
			}

		});

		return error_free;
	});

});

function clippyCopiedCallback() {
  $('#api_key_copied').fadeIn().delay(1000).fadeOut();

  // var b = $("#clippy_tooltip_" + a);
  // b.length != 0 && (b.attr("title", "copied!").trigger("tipsy.reload"), setTimeout(function() {
  //   b.attr("title", "copy to clipboard")
  // },
  // 500))
}

// Logging function that accounts for browsers that don't have window.console
function log(){
  log.history = log.history || [];
  log.history.push(arguments);
  if(this.console){
    console.log( Array.prototype.slice.call(arguments)[0] );
  }
}

// Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913)
if (Function.prototype.bind && console && typeof console.log === "object") {
    [
      "log","info","warn","error","assert","dir","clear","profile","profileEnd"
    ].forEach(function (method) {
        console[method] = this.bind(console[method], console);
    }, Function.prototype.call);
}

window.Docs = {

	shebang: function() {

		// If shebang has an operation nickname in it..
		// e.g. /docs/#!/words/get_search
		var fragments = $.param.fragment().split('/');
		fragments.shift(); // get rid of the bang

		switch (fragments.length) {
			case 1:
        if (fragments[0].length > 0) { // prevent matching "#/"
          // Expand all operations for the resource and scroll to it
          var dom_id = 'resource_' + fragments[0];

          Docs.expandEndpointListForResource(fragments[0]);
          $("#"+dom_id).slideto({highlight: false});
        }
				break;
			case 2:
				// Refer to the endpoint DOM element, e.g. #words_get_search

        // Expand Resource
        Docs.expandEndpointListForResource(fragments[0]);
        $("#"+dom_id).slideto({highlight: false});

        // Expand operation
				var li_dom_id = fragments.join('_');
				var li_content_dom_id = li_dom_id + "_content";

				Docs.expandOperation($('#'+li_content_dom_id));
				$('#'+li_dom_id).slideto({highlight: false});
				break;
		}

	},

	toggleEndpointListForResource: function(resource) {
		var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints');
		if (elem.is(':visible')) {
			$.bbq.pushState('#/', 2);
			Docs.collapseEndpointListForResource(resource);
		} else {
            $.bbq.pushState('#/' + resource, 2);
			Docs.expandEndpointListForResource(resource);
		}
	},

	// Expand resource
	expandEndpointListForResource: function(resource) {
		var resource = Docs.escapeResourceName(resource);
		if (resource == '') {
			$('.resource ul.endpoints').slideDown();
			return;
		}

		$('li#resource_' + resource).addClass('active');

		var elem = $('li#resource_' + resource + ' ul.endpoints');
		elem.slideDown();
	},

	// Collapse resource and mark as explicitly closed
	collapseEndpointListForResource: function(resource) {
		var resource = Docs.escapeResourceName(resource);
		if (resource == '') {
			$('.resource ul.endpoints').slideUp();
			return;
		}

		$('li#resource_' + resource).removeClass('active');

		var elem = $('li#resource_' + resource + ' ul.endpoints');
		elem.slideUp();
	},

	expandOperationsForResource: function(resource) {
		// Make sure the resource container is open..
		Docs.expandEndpointListForResource(resource);

		if (resource == '') {
			$('.resource ul.endpoints li.operation div.content').slideDown();
			return;
		}

		$('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
			Docs.expandOperation($(this));
		});
	},

	collapseOperationsForResource: function(resource) {
		// Make sure the resource container is open..
		Docs.expandEndpointListForResource(resource);

		if (resource == '') {
			$('.resource ul.endpoints li.operation div.content').slideUp();
			return;
		}

		$('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
			Docs.collapseOperation($(this));
		});
	},

	escapeResourceName: function(resource) {
		return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&");
	},

	expandOperation: function(elem) {
		elem.slideDown();
	},

	collapseOperation: function(elem) {
		elem.slideUp();
	}
};
<commit_msg>formatting<commit_after>'use strict';

$(function() {

	// Helper function for vertically aligning DOM elements
	// http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/
	$.fn.vAlign = function() {
		return this.each(function(){
			var ah = $(this).height();
			var ph = $(this).parent().height();
			var mh = (ph - ah) / 2;
			$(this).css('margin-top', mh);
		});
	};

	$.fn.stretchFormtasticInputWidthToParent = function() {
		return this.each(function(){
			var p_width = $(this).closest("form").innerWidth();
			var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest('form').css('padding-right'), 10);
			var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10);
			$(this).css('width', p_width - p_padding - this_padding);
		});
	};

	$('form.formtastic li.string input, form.formtastic textarea').stretchFormtasticInputWidthToParent();

	// Vertically center these paragraphs
	// Parent may need a min-height for this to work..
	$('ul.downplayed li div.content p').vAlign();

	// When a sandbox form is submitted..
	$("form.sandbox").submit(function(){

		var error_free = true;

		// Cycle through the forms required inputs
 		$(this).find("input.required").each(function() {

			// Remove any existing error styles from the input
			$(this).removeClass('error');

			// Tack the error style on if the input is empty..
			if ($(this).val() === '') {
				$(this).addClass('error');
				$(this).wiggle();
				error_free = false;
			}

		});

		return error_free;
	});

});

function clippyCopiedCallback() {
  $('#api_key_copied').fadeIn().delay(1000).fadeOut();

  // var b = $("#clippy_tooltip_" + a);
  // b.length != 0 && (b.attr("title", "copied!").trigger("tipsy.reload"), setTimeout(function() {
  //   b.attr("title", "copy to clipboard")
  // },
  // 500))
}

// Logging function that accounts for browsers that don't have window.console
function log(){
  log.history = log.history || [];
  log.history.push(arguments);
  if(this.console){
    console.log( Array.prototype.slice.call(arguments)[0] );
  }
}

// Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913)
if (Function.prototype.bind && console && typeof console.log === "object") {
    [
      "log","info","warn","error","assert","dir","clear","profile","profileEnd"
    ].forEach(function (method) {
        console[method] = this.bind(console[method], console);
    }, Function.prototype.call);
}

window.Docs = {

	shebang: function() {

		// If shebang has an operation nickname in it..
		// e.g. /docs/#!/words/get_search
		var fragments = $.param.fragment().split('/');
		fragments.shift(); // get rid of the bang

		switch (fragments.length) {
			case 1:
        if (fragments[0].length > 0) { // prevent matching "#/"
          // Expand all operations for the resource and scroll to it
          var dom_id = 'resource_' + fragments[0];

          Docs.expandEndpointListForResource(fragments[0]);
          $("#"+dom_id).slideto({highlight: false});
        }
				break;
			case 2:
				// Refer to the endpoint DOM element, e.g. #words_get_search

        // Expand Resource
        Docs.expandEndpointListForResource(fragments[0]);
        $("#"+dom_id).slideto({highlight: false});

            // Expand operation
            var li_dom_id = fragments.join('_');
            var li_content_dom_id = li_dom_id + "_content";

            Docs.expandOperation($('#'+li_content_dom_id));
            $('#'+li_dom_id).slideto({highlight: false});
            break;
		}
	},

	toggleEndpointListForResource: function(resource) {
		var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints');
		if (elem.is(':visible')) {
			$.bbq.pushState('#/', 2);
			Docs.collapseEndpointListForResource(resource);
		} else {
            $.bbq.pushState('#/' + resource, 2);
			Docs.expandEndpointListForResource(resource);
		}
	},

	// Expand resource
	expandEndpointListForResource: function(resource) {
		var resource = Docs.escapeResourceName(resource);
		if (resource == '') {
			$('.resource ul.endpoints').slideDown();
			return;
		}

		$('li#resource_' + resource).addClass('active');

		var elem = $('li#resource_' + resource + ' ul.endpoints');
		elem.slideDown();
	},

	// Collapse resource and mark as explicitly closed
	collapseEndpointListForResource: function(resource) {
		var resource = Docs.escapeResourceName(resource);
		if (resource == '') {
			$('.resource ul.endpoints').slideUp();
			return;
		}

		$('li#resource_' + resource).removeClass('active');

		var elem = $('li#resource_' + resource + ' ul.endpoints');
		elem.slideUp();
	},

	expandOperationsForResource: function(resource) {
		// Make sure the resource container is open..
		Docs.expandEndpointListForResource(resource);

		if (resource == '') {
			$('.resource ul.endpoints li.operation div.content').slideDown();
			return;
		}

		$('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
			Docs.expandOperation($(this));
		});
	},

	collapseOperationsForResource: function(resource) {
		// Make sure the resource container is open..
		Docs.expandEndpointListForResource(resource);

		if (resource == '') {
			$('.resource ul.endpoints li.operation div.content').slideUp();
			return;
		}

		$('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
			Docs.collapseOperation($(this));
		});
	},

	escapeResourceName: function(resource) {
		return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&");
	},

	expandOperation: function(elem) {
		elem.slideDown();
	},

	collapseOperation: function(elem) {
		elem.slideUp();
	}
};
<|endoftext|>


<commit_before>var Twit = require('twit'),
    redis = require('redis'),
    config = require('./config')

var T = new Twit(config),
    db = redis.createClient(),
    stream = T.stream('user')

stream.on('connect', function (request) {
  console.log('Connected to stream...')
})

stream.on('reconnect', function (request, response, connectInterval) {
  console.log('reconnecting to stream...')
})

/**
 * Twitter sent a disconnect message to us
 */
stream.on('disconnect', function (disconnectMessage) {
  console.log('Disconnected from stream!')
  console.log(disconnectMessage)
  quit()
})

stream.on('tweet', function (tweet) {
  console.log('set tweet:'+tweet.id_str)
  db.set('tweet:'+tweet.id_str, JSON.stringify(tweet), redis.print)
  db.expire('tweet:'+tweet.id_str, 604800, redis.print) // 7 days
  db.lpush('timeline', tweet.id_str, redis.print)
})

stream.on('error', function(err) {
  console.log('Stream error!')
  console.log(err)
  quit()
})

/**
 * Quit and cleanup
 */
function quit() {
  stream.stop()
  db.quit()
}
<commit_msg>Add tweets to redis rated list by timestamp<commit_after>var Twit = require('twit'),
    redis = require('redis'),
    config = require('./config')

var T = new Twit(config),
    db = redis.createClient(),
    stream = T.stream('user')

stream.on('connect', function (request) {
  console.log('Connected to stream...')
})

stream.on('reconnect', function (request, response, connectInterval) {
  console.log('reconnecting to stream...')
})

/**
 * Twitter sent a disconnect message to us
 */
stream.on('disconnect', function (disconnectMessage) {
  console.log('Disconnected from stream!')
  console.log(disconnectMessage)
  quit()
})

stream.on('tweet', function (tweet) {
  console.log('set tweet:'+tweet.id_str)
  var created_at_regex = /^(\w{3}) (\w{3}) (\d{2}) (\d{2}:\d{2}:\d{2}) \+0000 (\d{4})/
  var created_at = created_at_regex.exec(tweet.created_at)
  var date = new Date(created_at[1]+", "+created_at[3]+" "+created_at[2]+" "+created_at[5]+" "+created_at[4]+" +0000")
  console.log(tweet.created_at, date, date.getTime())
  db.set('tweet:'+tweet.id_str, JSON.stringify(tweet), redis.print)
  db.expire('tweet:'+tweet.id_str, 604800, redis.print) // 7 days
  db.lpush('timeline', tweet.id_str, redis.print)
  db.zadd('timeline_sorted_epoch', date.getTime(), tweet.id_str, redis.print)
})

stream.on('error', function(err) {
  console.log('Stream error!')
  console.log(err)
  quit()
})

/**
 * Quit and cleanup
 */
function quit() {
  stream.stop()
  db.quit()
}
<|endoftext|>