Turns the bundles into their slim version (mutates stream data)
@param {Object} data - The slim stream data object
@param {Object} options - An options object
@return {Object} The mutated data
163259
function doSlimGrap(data, options) {
	var bundles = data.bundles.slice(0);

	var slimmedBundles = slimGraph({
		graph: data.graph,
		mains: data.mains,
		bundles: bundles,
		target: options.target,
		baseUrl: data.loader.baseURL,
		slimConfig: data.loader.slimConfig,
		splitLoader: data.options.splitLoader,
		bundlesPath: data.configuration.bundlesPath,
		configMain: data.loader.configMain || "package.json!npm",
		progressiveBundles: getProgressiveBundles(data.loader, data.graph)
	});

	return assign(
		{},
		omit(data, ["bundles"]),
		{ bundles: slimmedBundles }
	);
}
765877
function Stream (options) {

  //check options
  if (!options) {

    throw new Error('Initialization error: missing transport options')
  }

  this._initDefaults() //Initialize default params
  this._updateParams(options)
  this._initTransport(options.transport)

  var self = this

  self.on('error', nop)

  this.subscriptions = []

  this.getSubscriptions = function () {

    return this.subscriptions
  }

  this.addSubscription = function (args, callback) {

    var c = new Subscription(args, callback, this)
    this.subscriptions[c.eid] = c
    return c
  }

  this.getSubscription = function (channel, resource) {

    if (this.subscriptions[channel + this.seperator + resource]) {
      return this.subscriptions[channel + this.seperator + resource]
    }
    return null
  }

  this.getAnySubscription = function (channel, resource) {

    if (this.subscriptions[channel + this.seperator + resource]) {
      return this.subscriptions[channel + this.seperator + resource]
    } else if (this.subscriptions[channel + this.seperator + this.wildcard]) {
      return this.subscriptions[channel + this.seperator + this.wildcard]
    } else {
      return null
    }
  }

  this.removeSubscription = function (channel, resource) {

    resource = resource || this.wildcard
    if (this.subscriptions[channel + this.seperator + resource]) {
      var retval = this.subscriptions[channel + this.seperator + resource]
      delete this.subscriptions[channel + this.seperator + resource]
      return retval
    }

    return null
  }

  this.getSubscriptionWithPermission = function (channel, resource, read, write) {

    var Subscription = this.subscriptions[channel + this.seperator + resource]
    var match = false

    if (Subscription) {

      match = true

      if (read) {
        match = Subscription.hasReadPermission()
      }

      if (write) {
        match = Subscription.hasWritePermission()
      }

      if (match) {
        return Subscription
      }
    } else {

      Subscription = this.subscriptions[channel + this.seperator + this.wildcard]

      if (Subscription) {

        match = true

        if (read) {
          match = Subscription.hasReadPermission()
        }

        if (write) {
          match = Subscription.hasWritePermission()
        }

        if (match) {
          return Subscription
        }
      }
    }

    return null
  }

  this.connection = new this.ConnectionFactory(this)
  this.connect()
}
180144
function Data(options) {
  if (!(this instanceof Data)) {
    return new Data(options);
  }
  var opts = utils.merge({cwd: path.resolve(__dirname, '../../.data')}, options);
  Base.call(this, null, opts);
  this.define('store', utils.store('npm-api', this.options));
}
930193
function extend(data) {
	return {
		
		uid   : typeof data.uid === 'string' ? data.uid : null,
		title : data.title || 'Unnamed',
		kind  : data.kind || 'fold',
		value : data.value !== undefined ? data.value : null,
		
		isOpen  : ( !! data.isOpen ) || false,
		subtree : data.subtree || [],
		
	};
}
182593
async function convertStream(data, streaming) {
  if (!streaming && util.isStream(data)) {
    return stream.readToEnd(data);
  }
  if (streaming && !util.isStream(data)) {
    data = new ReadableStream({
      start(controller) {
        controller.enqueue(data);
        controller.close();
      }
    });
  }
  if (streaming === 'node') {
    data = stream.webToNode(data);
  }
  return data;
}
756172
function compile( bundleData, bundleFile, config, callback ) {
	var baseDir = config['path'] || path.dirname(bundleFile);
	var encoder, profileEncoder = [], profileLoader = [], bundleLoader;

	// Compile stages
	var openBundle = function( cb ) {
		return function() {

			// Create encoder
			encoder = new BinaryEncoder(
					bundleFile,
					{
						'name' 			: bundleData['name'],
						'base_dir' 		: baseDir,
						'log'			: config['log'] || 0x00,
						'sparse'		: config['sparse'],
					}
				);

			// Add profiles
			for (var i=0; i<profileEncoder.length; i++) {
				encoder.addProfile( profileEncoder[i] );
			}

			// We are ready
			cb();
		}
	}

	var loadBundles = function( cb ) {
		return function() {
			// Load a bundle by specs
			bundleLoader.addBySpecs( bundleData );
			// Solve dependencies and load resources
			bundleLoader.load( cb );
		}
	}

	var compileExports = function( cb ) {
		return function() {
			// Get the bundle to encode
			var bundle = bundleLoader.bundles[ bundleData['name'] ];

			// Encode resources
			for (var k in bundle.resources) {
				encoder.encode( bundle.resources[k], k );
			}

			// Embed blobs
			for (var k in bundle.blobs) {
				encoder.embedBlob( bundle.blobs[k][0], k, bundle.blobs[k][1] );
			}

			// We are done
			cb();
		}
	}

	var closeBundle = function( cb ) {
		return function() {
			// Close & Complete
			encoder.close();
			cb();
		}
	}

	// Check for profileTable/profileLoader
	if (config['profileEncoder'] || config['profileLoader']) {

		// Check for missing arguments
		if (!config['profileEncoder']) {
			callback( "Got 'profileLoader' but missing 'profileEncoder' in the arguments" );
			return;
		}
		if (!config['profileLoader']) {
			callback( "Got 'profileEncoder' but missing 'profileLoader' in the arguments" );
			return;
		}

		// Fetch
		profileEncoder = config['profileEncoder'];
		profileLoader = config['profileLoader'];

		// Make sure it's array
		if (!(profileEncoder instanceof Array))
			profileEncoder = [ profileEncoder ];
		if (!(profileLoader instanceof Array))
			profileLoader = [ profileLoader ];

	} else {

		// Identify some important information
		var profile = config['profile'] || bundleData['profile'];
		if (!profile) {
			callback( "No jbb profile was specified!");
			return;
		}

		// Make sure it's array
		if (typeof profile === 'string')
			profile = [ profile ];

		// Require
		for (var i=0; i<profile.length; i++) {
			var pname = profile[i];
			if (pname[0] == ".") {
				profileEncoder.push( require( path.join(process.cwd(), pname, '/profile-encode') ) );
				profileLoader.push( require( path.join(process.cwd(), pname, "/profile-loader") ) );
			} else {
				profileEncoder.push( require('jbb-profile-'+pname+'/profile-encode') );
				profileLoader.push( require('jbb-profile-'+pname+"/profile-loader") );
			}
		}

	}

	// Load profile table and compiler helper
	bundleLoader = new BundlesLoader( baseDir );
	for (var i=0; i<profileLoader.length; i++) {
		bundleLoader.addProfileLoader( profileLoader[i] );
	}

	// Chained initialization of profile loaders
	var context = { 'remaining': profileLoader.length }
	var init_callback = (function() {
		if (--this.remaining == 0) {
			openBundle(
				loadBundles(
					compileExports(
						closeBundle( callback || function(){} )
						) 
					) 
			)();
		}
	}).bind(context);

	// Initialize profile compiler with the specs file
	for (var i=0; i<profileLoader.length; i++) {
		if (!profileLoader[i].initialize) {
			init_callback();
		} else {
			profileLoader[i].initialize( init_callback, bundleData );
		}
	}

}
238547
function bundle (ids = []) {
      ids.forEach((id) => {
        if (!muted.has(id)) {
          console.info(chalk.cyan('change:'), path.relative(process.cwd(), id))
          muted.add(id)
        }
      })

      const exampleName = path.basename(path.dirname(file))
      const output = dstPattern.replace('**', exampleName)
      const parentDir = path.dirname(output)

      mkdirp.sync(parentDir)

      console.info(chalk.grey(`⏳ building: ${path.relative(process.cwd(), file)}`))

      b
        .bundle()
        .on('error', onError)
        .pipe(createStream(output))
        .on('finish', () => {
          console.info(chalk.green(`✓ built: ${path.relative(process.cwd(), file)}`))
        })
    }
683228
function __serializeContent(data, options=DEFAULT_OPTIONS) {
	let type = __getType(data, options);
	let typeBuffer	= __serializeType(type, options);
	let dataBuffers = __serializeData(type, data, options);
	return [typeBuffer, ...dataBuffers];
}
799356
public function make($data, $options=array())
	{
		// Options
		$this->options = array_merge($this->options, $options);
		$options       = $this->options;

		// Capture output
		$out  = [];

		// @todo - Raise an exception instead ?
		// Would make more send and could be handled more gracefully
		//
		// Have any records actually been passed through ?
		if (empty($data)) {
			return $this->hasNoData($options);
		}

		// If a 'id' key has been specified use that as the table#id
		$tableId = null;

		if (!empty($options['id'])) {
			$tableId = "id='{$options['id']}'";
		}

		$out[] = "<div class=\"{$options['wrapperClass']}\">";
		$out[] = "\t<table class='{$options['containerClass']}' {$tableId}>";

		// Render headers
		if (true == $options['showHeaders']) {
			$headers = $this->extractHeaders($data);

			$out[] = "\t\t<thead>\r\t\t\t<tr class=\"{$options['headerClass']}\">";
			$count = 1;

			/**
			 * Create the <th> tag
			 */
			foreach ($headers as $index => $header)
			{
				$class = $this->getHeaderClass($header, $count);
				$count++;

				// Apply sort links to header
				if (isset($options['sort'][$header])) {

					$sortBy = $options['sort'][$header];
					$label  = $header;

					$header = $this->applyHeaderSort($label, $sortBy);
				}

				$out[] = "\t\t\t\t<th class=\"{$class}\">{$header}</th>";
			}

			$out[] = "\t\t\t</tr>\r\t\t</thead>";
		}

		$out[] = "\t\t<tbody>";

		// Render rows
		foreach ($data as $index => $row)
		{
			$rowClass = ($index % 2 == 0) ? $options['rowClass'] : $options['rowClassAlt'];

			if (isset($row['id'])) {
				$out[] = "\t\t\t<tr class='{$rowClass}' id='{$row['id']}-{$row['id']}'>";
			} else {
				$out[] = "\t\t\t<tr class='{$rowClass}'>";
			}

			foreach ($row as $field => $value) {
				$indent = "";
				if ($field == 'Title' && isset($options['type']) && $options['type'] == 'table-tree') {
					if (!empty($row['parent_id'])) {
						$indent = str_repeat($options['indent_style'], $row['depth']);
					}
				}

				if (in_array($field, $options['hiddenFields'], true)) {
					continue;
				}

				$fieldClass = $options['fieldClass'];

				if (is_array($value)) {
					//Log::info('@todo - Replace with logging interface');
					//$value = implode(',' $value);
					$value = 'Array';
				}

				$out[] = "\t\t\t\t<td class=\"{$fieldClass}\">{$value}</td>";

			}

			$out[] = "\t\t\t</tr>";
		}

		$out[] = "\t\t</tbody>";
		$out[] = "\t</table>";
		$out[] = "</div>";

		$this->output['table'] = implode(PHP_EOL, $out);

		return $this;
	}
552827
function (data) {
      var include = function (path, includeData) {
        var d = utils.shallowCopy({}, data);
        if (includeData) {
          d = utils.shallowCopy(d, includeData);
        }
        var p = includeFile(path, opts)(d);
        return p;
      };
      
      var error = null;
      
      var outputStreamOpts = utils.shallowCopy({}, opts.streamOptions);
      var outputStreamBufferOpts = utils.shallowCopy({}, opts.streamOptions);
      outputStreamBufferOpts.flush = function (cb) {
        cb(error);
      }
      
      var outputStream = new PassThrough(outputStreamOpts);
      var outputStreamBuffer = new PassThrough(outputStreamBufferOpts);
      
      // outputStream.write('');
      outputStream.pipe(outputStreamBuffer);
      
      var p = utils.wrapToPromise(fn, opts.context, Promise, data || {}, escape, include, rethrow, Promise, utils.wrapToPromise, outputStream, Stream);
      
      p.shouldUseBuffer = true;
      p.noBuffer = function () {
        p.outputBuffer = ""
        p.shouldUseBuffer = false;
      }
      p.useBuffer = function () {
        p.shouldUseBuffer = true;
      }
      
      
      // do not continue the script if it is not appropriate to resume writing data to the stream.
      // https://nodejs.org/api/stream.html#stream_event_drain
      p.shouldWaitFlush = false;
      Object.defineProperty(outputStream, 'shouldWaitFlush', {
        get: function () {
          return p.shouldWaitFlush
        },
        set: function (val) {
          p.shouldWaitFlush = val
          return true;
        }
      })
      p.waitFlush = function () {
        p.shouldWaitFlush = true;
      }
      p.noWaitFlush = function () {
        p.shouldWaitFlush = false;
      }
      
      
      p.outputBuffer = ""
      // since the stream got consumed immediatly, we need another stream to buffer it;
      p.outputStream = outputStreamBuffer;
      // a test only property
      p._outputStream = outputStream;
      // since we need to escape the text, and escape only works on string
      outputStream.setEncoding('utf8');
      
      // redirect data to the buffer
      outputStream.on('data', function (data) {
        if (!p.shouldUseBuffer) return;
        p.outputBuffer += data;
      })
      
      // resolve the promise after stream end, so we can get all data.
      outputStream.on('end', function (data) {
        p.defered.resolve(p.outputBuffer)
      })
      
      // hook after generator exit normally
      p.defered.onResolve = function (defered) {
        outputStream.end();
        // force it to flush all buffer since a pipe to fulfilled target prohibit
        // the stream from flushing the data
        // outputStream.uncork();
        
        // use read directly, since uncork sometimes fail to dunp the stream
        while (outputStream.read()) {}
      }
      
      // hook for situation the generator throws
      p.defered.onReject = function (defered, err) {
        // the promise should be reject before stream got end, 
        // or it will cause the stream to think it terminate normally, 
        // since there is not any error event before the end event and promise reject
        defered.reject(err)
        
        // emit only if the user decide to listen to stream's error event instead of promise reject
        // the stream.pipe bind a error listener to stream, so we need to count it
        if (outputStreamBuffer.listenerCount('error') > 1) {
          error = err;
        }
        outputStream.end();
        // force it to flush all buffer since a pipe to fulfilled target prohibit
        // the stream from flushing the data
        // outputStream.uncork();
        
        // use read directly, since uncork sometimes fail to dunp the stream
        while (outputStream.read()) {}
      }
      
      // terminate the stream, prevent further writing
      p.defered.onInterrupt = function (cb) {
        outputStream.end();
        cb();
      }
      
      setTimeout(function() {
        p.execute();
      }, 0)
      return p;
    }
1292335
function convertFileType (data) {
  data['type'] = 'file'
  const anyOf = data.media.anyOf
  if (anyOf && anyOf.length > 0) {
    data['fileTypes'] = []
    anyOf.forEach(function (el) {
      if (el.mediaType) {
        data.fileTypes.push(el.mediaType)
      }
    })
    if (data.fileTypes.length < 1) {
      delete data.fileTypes
    }
  }
  delete data.media
  return data
}
92537
function (data, options) {
      var rdf = this,
        options = options || {},
        success = options.success;
      if (success !== undefined) {
        options.success = function () {
          success.call(rdf);
        }
      }
      this.databank.load(data, options);
      return this;
    }
821262
function bundle(srcFiles, destDir, optionsFn) {
    return gulp.src(srcFiles, {
        read: false
    })
    .pipe(tap(function(file) {
        var options = {};
        if (optionsFn) options = optionsFn(file);
        var fileName = options.fileName || path.basename(file.path);

        if (options.standalone)
            console.log(`Creating ${options.standalone} in ${destDir}/${fileName}`);
        else
            console.log(`Creating ${destDir}/${fileName}`);

        file.contents = browserify(file.path, options)
            .ignore("buffer")
            .ignore("dotenv")
        .bundle()
            .on("error", function (err) {
                console.log(err);
            });
        file.path = path.join(file.base, fileName);
    }))
    .pipe(buffer())
    .pipe(sourcemaps.init({
        loadMaps: true
    }))
    .pipe(uglify({
        preserveComments: function(node, comment) {
            return comment.value.includes("Copyright Arm");
        }
    }))
    .pipe(sourcemaps.write(".", {
        sourceRoot: path.relative(destDir, nodeDir)
    }))
    .pipe(gulp.dest(destDir));
}
268249
function (data) {
        var items = [];
        data.forEach(function (d, i) {
            if (d.includes('ITEM:') && d.length > 3) {
                var iid = data[i + 1];
                var item = {
                    item: {
                        id: Number(iid[1].trim()),
                        name: d[2].replace(/_/g, ' '),
                        price: d[3],
                        change: d[4]
                    }
                };
                items.push(item);
            }
        });
        return items;
    }
617941
function serializeData(options) {
    if (isObject(options.data)) options.data = $.param(options.data)
    if (options.data && (!options.type || options.type.toUpperCase() == 'GET'))
      options.url = appendQuery(options.url, options.data)
  }
170006
function addPluginName(data) {
	var loader = data.loader;
	var bundles = data.bundles;

	var promises = bundles.map(function(bundle) {
		if (!isJavaScriptBundle(bundle)) {
			return loader.normalize(bundle.name).then(function(name) {
				bundle.pluginName = name.substring(name.indexOf("!") + 1);
			});
		}
	});

	return Promise.all(promises).then(function() {
		return data;
	});
}
277015
function serializeData(options) {
    if (options.processData && options.data && $.type(options.data) != "string")
      options.data = $.param(options.data, options.traditional)
    if (options.data && (!options.type || options.type.toUpperCase() == 'GET'))
      options.url = appendQuery(options.url, options.data)
  }