_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q26900 | train | function (customizations, layoutConfig) {
var customization = customizations[layoutConfig.view.type];
if (!customization) {
return layoutConfig;
}
return _.merge(layoutConfig, { view: customization });
} | javascript | {
"resource": ""
} | |
q26901 | MetricsProvider | train | function MetricsProvider(screen) {
/**
* Setup the process to aggregate the data as and when it is necessary.
*
* @returns {void}
*/
var setupAggregation =
function setupAggregation() {
// construct the aggregation container
this._aggregation = _.reduce(AGGREGATE_TIME_... | javascript | {
"resource": ""
} |
q26902 | getInitializedAverage | train | function getInitializedAverage(data) {
return _.reduce(data, function (prev, a, dataKey) {
// create a first-level object of the key
prev[dataKey] = {};
_.each(data[dataKey], function (b, dataMetricKey) {
// the metrics are properties inside this object
prev[dataKey][dataMetricKey... | javascript | {
"resource": ""
} |
q26903 | aggregateMetrics | train | function aggregateMetrics(currentTime, metricData) {
var aggregateKey;
/**
* Place aggregate data into the specified slot. If the current zoom
* level matches the aggregate level, the data is emitted to keep the
* display in sync.
*
* @param {Number} index
* The desired slot for ... | javascript | {
"resource": ""
} |
q26904 | getAveragedAggregate | train | function getAveragedAggregate(rows, startIndex, endIndex) {
var averagedAggregate = getInitializedAverage(metricData);
// this is the number of elements we will aggregate
var aggregateCount = endIndex - startIndex + 1;
// you can compute an average of a set of numbers two ways
... | javascript | {
"resource": ""
} |
q26905 | getFixedScrollOffset | train | function getFixedScrollOffset(offset, length) {
if (offset && length + offset <= limit) {
return Math.min(limit - length, 0);
}
return Math.min(offset, 0);
} | javascript | {
"resource": ""
} |
q26906 | train | function(logType, logSection) {
if (!enabled) return;
var args = Array.prototype.slice.call(arguments, 2);
args.splice(0, 0, colors[logType][0]+"["+logType+"]"+colors[logType][1]+"["+logSection+"]");
console.log.apply(console, args);
} | javascript | {
"resource": ""
} | |
q26907 | mousemove_callback | train | function mousemove_callback(e) {
var x = e.pageX || e.originalEvent.touches[0].pageX;
var y = e.pageY || e.originalEvent.touches[0].pageY;
if (Math.abs(oX - x) > maxMove || Math.abs(oY - y) > maxMove) {
if (timeout) clearTimeout(timeout);
}
} | javascript | {
"resource": ""
} |
q26908 | train | function() {
var context, main, pkgRequireConfig, pkgRequire, that = this
var d = Q.defer();
if (!this.get("browser")) return Q();
logger.log("Load", this.get("name"));
getScript(this.url()+"/pkg-build.js", function(err) {
if (!err) return d.resolve();
... | javascript | {
"resource": ""
} | |
q26909 | cleanFolder | train | function cleanFolder(outPath) {
try {
var stat = fs.lstatSync(outPath);
if (stat.isDirectory()) {
wrench.rmdirSyncRecursive(outPath);
} else {
fs.unlinkSync(outPath);
}
} catch (e) {
if (e.code != "ENOENT") throw e;
}
} | javascript | {
"resource": ""
} |
q26910 | cleanseText | train | function cleanseText( options, cb ) {
return function( error, text ) {
if ( !error ) {
// clean up text
text = util.replaceBadCharacters( text );
if ( options.preserveLineBreaks || options.preserveOnlyMultipleLineBreaks ) {
if ( options.preserveOnlyMultipleLineBreaks ) {
text ... | javascript | {
"resource": ""
} |
q26911 | replaceBadCharacters | train | function replaceBadCharacters( text ) {
var i, repl;
for ( i = 0; i < rLen; i++ ) {
repl = replacements[i];
text = text.replace( repl[0], repl[1] );
}
return text;
} | javascript | {
"resource": ""
} |
q26912 | runExecIntoFile | train | function runExecIntoFile( label, filePath, options, execOptions, genCommand, cb ) {
// escape the file paths
var fileTempOutPath = path.join( outDir, path.basename( filePath, path.extname( filePath ) ) )
, escapedFilePath = filePath.replace( /\s/g, '\\ ' )
, escapedFileTempOutPath = fileTempOutPath.replace(... | javascript | {
"resource": ""
} |
q26913 | extractText | train | function extractText( filePath, options, cb ) {
var result = ''
, error = null
, textutil = spawn( 'textutil', ['-convert', 'txt', '-stdout', filePath] )
;
textutil.stdout.on( 'data', function( buffer ) {
result += buffer.toString();
});
textutil.stderr.on( 'error', function( buffer ) {
if... | javascript | {
"resource": ""
} |
q26914 | yamlParse | train | function yamlParse (text, reviver) {
try {
return yaml.safeLoad(text);
}
catch (e) {
if (e instanceof Error) {
throw e;
}
else {
// https://github.com/nodeca/js-yaml/issues/153
throw ono(e, e.message);
}
}
} | javascript | {
"resource": ""
} |
q26915 | yamlStringify | train | function yamlStringify (value, replacer, space) {
try {
var indent = (typeof space === "string" ? space.length : space) || 2;
return yaml.safeDump(value, { indent: indent });
}
catch (e) {
if (e instanceof Error) {
throw e;
}
else {
// https://github.com/nodeca/... | javascript | {
"resource": ""
} |
q26916 | parseJSON | train | function parseJSON (file) {
return new Promise(function (resolve, reject) {
var data = file.data;
if (Buffer.isBuffer(data)) {
data = data.toString();
}
if (typeof data === "string") {
if (data.trim().length === 0) {
resolve(undefined); // This mirrors the YAML be... | javascript | {
"resource": ""
} |
q26917 | parse | train | function parse (path, $refs, options) {
try {
// Remove the URL fragment, if any
path = url.stripHash(path);
// Add a new $Ref for this file, even though we don't have the value yet.
// This ensures that we don't simultaneously read & parse the same file multiple times
var $ref = $refs._add(path)... | javascript | {
"resource": ""
} |
q26918 | parseFile | train | function parseFile (file, options) {
return new Promise(function (resolve, reject) {
// console.log('Parsing %s', file.url);
// Find the parsers that can read this file type.
// If none of the parsers are an exact match for this file, then we'll try ALL of them.
// This handles situations where the f... | javascript | {
"resource": ""
} |
q26919 | isEmpty | train | function isEmpty (value) {
return value === undefined ||
(typeof value === "object" && Object.keys(value).length === 0) ||
(typeof value === "string" && value.trim().length === 0) ||
(Buffer.isBuffer(value) && value.length === 0);
} | javascript | {
"resource": ""
} |
q26920 | merge | train | function merge (target, source) {
if (isMergeable(source)) {
var keys = Object.keys(source);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var sourceSetting = source[key];
var targetSetting = target[key];
if (isMergeable(sourceSetting)) {
// It's a nested object, ... | javascript | {
"resource": ""
} |
q26921 | isMergeable | train | function isMergeable (val) {
return val &&
(typeof val === "object") &&
!Array.isArray(val) &&
!(val instanceof RegExp) &&
!(val instanceof Date);
} | javascript | {
"resource": ""
} |
q26922 | crawl | train | function crawl (obj, path, $refs, options) {
var promises = [];
if (obj && typeof obj === "object") {
if ($Ref.isExternal$Ref(obj)) {
promises.push(resolve$Ref(obj, path, $refs, options));
}
else {
Object.keys(obj).forEach(function (key) {
var keyPath = Pointer.join(path, key);
... | javascript | {
"resource": ""
} |
q26923 | resolve$Ref | train | function resolve$Ref ($ref, path, $refs, options) {
// console.log('Resolving $ref pointer "%s" at %s', $ref.$ref, path);
var resolvedPath = url.resolve(path, $ref.$ref);
var withoutHash = url.stripHash(resolvedPath);
// Do we already have this $ref?
$ref = $refs._$refs[withoutHash];
if ($ref) {
// We... | javascript | {
"resource": ""
} |
q26924 | crawl | train | function crawl (parent, key, path, pathFromRoot, indirections, inventory, $refs, options) {
var obj = key === null ? parent : parent[key];
if (obj && typeof obj === "object") {
if ($Ref.isAllowed$Ref(obj)) {
inventory$Ref(parent, key, path, pathFromRoot, indirections, inventory, $refs, options);
}
... | javascript | {
"resource": ""
} |
q26925 | parseText | train | function parseText (file) {
if (typeof file.data === "string") {
return file.data;
}
else if (Buffer.isBuffer(file.data)) {
return file.data.toString(this.encoding);
}
else {
throw new Error("data is not text");
}
} | javascript | {
"resource": ""
} |
q26926 | getPaths | train | function getPaths ($refs, types) {
var paths = Object.keys($refs);
// Filter the paths by type
types = Array.isArray(types[0]) ? types[0] : Array.prototype.slice.call(types);
if (types.length > 0 && types[0]) {
paths = paths.filter(function (key) {
return types.indexOf($refs[key].pathType) !==... | javascript | {
"resource": ""
} |
q26927 | Pointer | train | function Pointer ($ref, path, friendlyPath) {
/**
* The {@link $Ref} object that contains this {@link Pointer} object.
* @type {$Ref}
*/
this.$ref = $ref;
/**
* The file path or URL, containing the JSON pointer in the hash.
* This path is relative to the path of the main JSON schema file.
* @ty... | javascript | {
"resource": ""
} |
q26928 | dereference | train | function dereference (parser, options) {
// console.log('Dereferencing $ref pointers in %s', parser.$refs._root$Ref.path);
var dereferenced = crawl(parser.schema, parser.$refs._root$Ref.path, "#", [], parser.$refs, options);
parser.$refs.circular = dereferenced.circular;
parser.schema = dereferenced.value;
... | javascript | {
"resource": ""
} |
q26929 | crawl | train | function crawl (obj, path, pathFromRoot, parents, $refs, options) {
var dereferenced;
var result = {
value: obj,
circular: false
};
if (obj && typeof obj === "object") {
parents.push(obj);
if ($Ref.isAllowed$Ref(obj, options)) {
dereferenced = dereference$Ref(obj, path, pathFr... | javascript | {
"resource": ""
} |
q26930 | dereference$Ref | train | function dereference$Ref ($ref, path, pathFromRoot, parents, $refs, options) {
// console.log('Dereferencing $ref pointer "%s" at %s', $ref.$ref, path);
var $refPath = url.resolve(path, $ref.$ref);
var pointer = $refs._resolve($refPath, options);
// Check for circular references
var directCircular = ... | javascript | {
"resource": ""
} |
q26931 | readHttp | train | function readHttp (file) {
var u = url.parse(file.url);
if (process.browser && !u.protocol) {
// Use the protocol of the current page
u.protocol = url.parse(location.href).protocol;
}
return download(u, this);
} | javascript | {
"resource": ""
} |
q26932 | get | train | function get (u, httpOptions) {
return new Promise(function (resolve, reject) {
// console.log('GET', u.href);
var protocol = u.protocol === "https:" ? https : http;
var req = protocol.get({
hostname: u.hostname,
port: u.port,
path: u.path,
auth: u.auth,
protocol: u.protocol... | javascript | {
"resource": ""
} |
q26933 | getResult | train | function getResult (obj, prop, file, callback) {
var value = obj[prop];
if (typeof value === "function") {
return value.apply(obj, [file, callback]);
}
if (!callback) {
// The synchronous plugin functions (canParse and canRead)
// allow a "shorthand" syntax, where the user can match
// files b... | javascript | {
"resource": ""
} |
q26934 | parseYAML | train | function parseYAML (file) {
return new Promise(function (resolve, reject) {
var data = file.data;
if (Buffer.isBuffer(data)) {
data = data.toString();
}
if (typeof data === "string") {
resolve(YAML.parse(data));
}
else {
// data is already a JavaScript va... | javascript | {
"resource": ""
} |
q26935 | normalizeArgs | train | function normalizeArgs (args) {
var path, schema, options, callback;
args = Array.prototype.slice.call(args);
if (typeof args[args.length - 1] === "function") {
// The last parameter is a callback function
callback = args.pop();
}
if (typeof args[0] === "string") {
// The first parameter is the ... | javascript | {
"resource": ""
} |
q26936 | promisesWrapper | train | function promisesWrapper(func) {
return (options, callback) => {
// options is an optional argument
if (typeof options === 'function') {
callback = options;
options = undefined;
}
options = options || {};
// just call the function otherwise wrap a prom... | javascript | {
"resource": ""
} |
q26937 | domReady | train | function domReady(callback) {
if (doc.readyState === "complete" || (doc.readyState !== "loading" && !doc.documentElement.doScroll))
setTimeout(() => callback && callback(), 0)
else {
let handler = () => {
doc.removeEventListener("DOMContentLoaded", handler, false)
win.rem... | javascript | {
"resource": ""
} |
q26938 | oReady | train | function oReady(o, callback) {
!!o && (callback && callback()) || setTimeout(() => oReady(o, callback), 10)
} | javascript | {
"resource": ""
} |
q26939 | isCyclic | train | function isCyclic (data) {
// Create an array that will store the nodes of the array that have already been iterated over
let seenObjects = [];
function detect (data) {
// If the data pass is an object
if (data && getType(data) === "Object") {
// If the data is... | javascript | {
"resource": ""
} |
q26940 | teardownAll | train | function teardownAll() {
var componentInfo = registry.findComponentInfo(this);
componentInfo && Object.keys(componentInfo.instances).forEach(function(k) {
var info = componentInfo.instances[k];
// It's possible that a previous teardown caused another component to teardown,
// so we ... | javascript | {
"resource": ""
} |
q26941 | train | function(name, context, partials, indent) {
var partial = partials[name];
if (!partial) {
return '';
}
if (this.c && typeof partial == 'string') {
partial = this.c.compile(partial, this.options);
}
return partial.ri(context, partials, indent);
} | javascript | {
"resource": ""
} | |
q26942 | train | function(val, ctx, partials, inverted, start, end, tags) {
var cx = ctx[ctx.length - 1],
t = null;
if (!inverted && this.c && val.length > 0) {
return this.ho(val, cx, partials, this.text.substring(start, end), tags);
}
t = val.call(cx);
if (typeof t == 'function') {
... | javascript | {
"resource": ""
} | |
q26943 | train | function(val, ctx, partials) {
var cx = ctx[ctx.length - 1];
var result = val.call(cx);
if (typeof result == 'function') {
result = result.call(cx);
}
result = coerceToString(result);
if (this.c && ~result.indexOf("{\u007B")) {
return this.c.compile(result, this.opti... | javascript | {
"resource": ""
} | |
q26944 | getOrCreateSwarm | train | function getOrCreateSwarm (cb) {
self.getSwarm(params.info_hash, (err, swarm) => {
if (err) return cb(err)
if (swarm) return cb(null, swarm)
self.createSwarm(params.info_hash, (err, swarm) => {
if (err) return cb(err)
cb(null, swarm)
})
})
} | javascript | {
"resource": ""
} |
q26945 | fromUInt64 | train | function fromUInt64 (buf) {
var high = buf.readUInt32BE(0) | 0 // force
var low = buf.readUInt32BE(4) | 0
var lowUnsigned = (low >= 0) ? low : TWO_PWR_32 + low
return (high * TWO_PWR_32) + lowUnsigned
} | javascript | {
"resource": ""
} |
q26946 | shallowClone | train | function shallowClone(obj) {
let result = {};
for (let p in obj) {
if (obj.hasOwnProperty(p)) {
result[p] = obj[p];
}
}
return result;
} | javascript | {
"resource": ""
} |
q26947 | deepClone | train | function deepClone(obj) {
let result = Array.isArray(obj) ? [] : {};
for (let p in obj) {
if (obj.hasOwnProperty(p) || Array.isArray(obj)) {
result[p] = (typeof obj[p] === 'object') ? deepClone(obj[p]) : obj[p];
}
}
return result;
} | javascript | {
"resource": ""
} |
q26948 | recurse | train | function recurse(object, state, callback) {
if (!state) state = {depth:0};
if (!state.depth) {
state = Object.assign({},defaultState(),state);
}
if (typeof object !== 'object') return;
let oPath = state.path;
for (let key in object) {
state.key = key;
state.path = state.p... | javascript | {
"resource": ""
} |
q26949 | getDefaultState | train | function getDefaultState() {
return { depth: 0, seen: new WeakMap(), top: true, combine: false, allowRefSiblings: false };
} | javascript | {
"resource": ""
} |
q26950 | hasIncomingEdge | train | function hasIncomingEdge(list, node) {
for (var i = 0, l = list.length; i < l; ++i) {
if (list[i].links.find(function(e,i,a){
return node._id == e;
})) return true;
}
return false;
} | javascript | {
"resource": ""
} |
q26951 | flatten | train | function flatten(obj,callback) {
let arr = [];
let iDepth, oDepth = 0;
let state = {identityDetection:true};
recurse(obj,state,function(obj,key,state){
let entry = {};
entry.name = key;
entry.value = obj[key];
entry.path = state.path;
entry.parent = obj;
e... | javascript | {
"resource": ""
} |
q26952 | optionalResolve | train | function optionalResolve(options) {
setupOptions(options);
return new Promise(function (res, rej) {
if (options.resolve)
loopReferences(options, res, rej)
else
res(options);
});
} | javascript | {
"resource": ""
} |
q26953 | getStuffAndDeleteSecret | train | function getStuffAndDeleteSecret(opts, someArgument) {
// We depend on "stuffs" repository.
const stuffs = opts.stuffs
// We may now carry on.
return stuffs.getStuff(someArgument).then(stuff => {
// Modify return value. Just to prove this is testable.
delete stuff.secret
return stuff
})
} | javascript | {
"resource": ""
} |
q26954 | get | train | function get () {
var listener = this.listeners(method)[0]
return listener ? (listener._listener ? listener._listener : listener) : undefined
} | javascript | {
"resource": ""
} |
q26955 | getBinaryUrl | train | function getBinaryUrl() {
var site = getArgument('--fis-binary-site') ||
process.env.FIS_BINARY_SITE ||
process.env.npm_config_FIS_binary_site ||
(pkg.nodeConfig && pkg.nodeConfig.binarySite) ||
'https://github.com/' + repositoryName + '/releases/download';
retu... | javascript | {
"resource": ""
} |
q26956 | deepClone | train | function deepClone(obj) {
if (obj && typeof obj === 'object') {
if (Array.isArray(obj)) {
var newObj = [];
for (var i = 0, j = obj.length; i < j; i++) {
newObj[i] = deepClone(obj[i]);
}
return newObj;
} else if (isPlainObj(obj)) {
var _newObj = {};
for (var _i in... | javascript | {
"resource": ""
} |
q26957 | profile | train | function profile(target, propertyKey, descriptor) {
if (flags_1.IS_PROFILE) {
return performProfile(target, propertyKey, descriptor);
}
else {
// return as-is
return descriptor;
}
} | javascript | {
"resource": ""
} |
q26958 | train | function(foo, self) {
return function() {
var arg, tmp, args = [];
for (var i = 0, l = arguments.length; i < l; i++) {
arg = arguments[i];
if (_isFunction(arg)) {
if (arg.tryWrap) {
arg = arg.tryWrap;
... | javascript | {
"resource": ""
} | |
q26959 | train | function(obj) {
var key, value;
for (key in obj) {
value = obj[key];
if (_isFunction(value)) obj[key] = cat(value);
}
return obj;
} | javascript | {
"resource": ""
} | |
q26960 | encasedCallback | train | function encasedCallback( e, namespace, triggeredElement ){
var result;
if( e._namespace && e._namespace !== namespace ) {
return;
}
e.data = data;
e.namespace = e._namespace;
var returnTrue = function(){
return true;
};
e.isDefaultPrevented = function(){
return false;
};
... | javascript | {
"resource": ""
} |
q26961 | checkBasicSupport | train | function checkBasicSupport(client, metadata, properties) {
try {
const supported = client.issuer.token_endpoint_auth_methods_supported;
if (!supported.includes(properties.token_endpoint_auth_method)) {
if (supported.includes('client_secret_post')) {
properties.token_endpoint_auth_method = 'clien... | javascript | {
"resource": ""
} |
q26962 | train | function (html) {
var $ = cheerio.load(html, {
decodeEntities: false,
lowerCaseAttributeNames: false,
lowerCaseTags: false
});
var output = {
style: $.html('style'),
script: $.html('script')
};
var result;
$('style').remove();
$('script').remove();
result = '<template><section>' +... | javascript | {
"resource": ""
} | |
q26963 | guessAppName | train | function guessAppName (compilerWorkingDirectory) {
var packageJson = path.resolve(compilerWorkingDirectory, 'package.json');
if (!fs.existsSync(packageJson)) {
packageJson = path.resolve(compilerWorkingDirectory, '../package.json');
if (!fs.existsSync(packageJson)) {
return 'Webpack App';
}
}
... | javascript | {
"resource": ""
} |
q26964 | emitCacheInformationFile | train | function emitCacheInformationFile (loader, query, cacheFile, fileHash, iconResult) {
if (!query.persistentCache) {
return;
}
loader.emitFile(cacheFile, JSON.stringify({
hash: fileHash,
version: pluginVersion,
optionHash: generateHashForOptions(query),
result: iconResult
}));
} | javascript | {
"resource": ""
} |
q26965 | isCacheValid | train | function isCacheValid (cache, fileHash, query) {
// Verify that the source file is the same
return cache.hash === fileHash &&
// Verify that the options are the same
cache.optionHash === generateHashForOptions(query) &&
// Verify that the favicons version of the cache maches this version
cache.versi... | javascript | {
"resource": ""
} |
q26966 | loadIconsFromDiskCache | train | function loadIconsFromDiskCache (loader, query, cacheFile, fileHash, callback) {
// Stop if cache is disabled
if (!query.persistentCache) return callback(null);
var resolvedCacheFile = path.resolve(loader._compiler.parentCompilation.compiler.outputPath, cacheFile);
fs.exists(resolvedCacheFile, function (exists... | javascript | {
"resource": ""
} |
q26967 | generateHashForOptions | train | function generateHashForOptions (options) {
var hash = crypto.createHash('md5');
hash.update(JSON.stringify(options));
return hash.digest('hex');
} | javascript | {
"resource": ""
} |
q26968 | getValueIfEnabled | train | function getValueIfEnabled(expr, source, path) {
if (!options.deep && expr.includes('@')) {
console.error(`[Vuex Pathify] Unable to access sub-property for path '${expr}':
- Set option 'deep' to 1 to allow it`)
return
}
return getValue(source, path)
} | javascript | {
"resource": ""
} |
q26969 | Get | train | function Get(path) {
if (typeof path !== 'string' || arguments.length > 1) { throw new Error('Property decorators can be used for single property access') }
return createDecorator((options, key) => {
if (!options.computed) options.computed = {}
options.computed[key] = get(path)
})
} | javascript | {
"resource": ""
} |
q26970 | Sync | train | function Sync(path) {
if (typeof path !== 'string' || arguments.length > 1) { throw new Error('Property decorators can be used for single property access') }
return createDecorator((options, key) => {
if (!options.computed) options.computed = {}
options.computed[key] = sync(path)
})
} | javascript | {
"resource": ""
} |
q26971 | Call | train | function Call(path) {
if (typeof path !== 'string' || arguments.length > 1) { throw new Error('Property decorators can be used for single property access') }
return createDecorator((options, key) => {
if (!options.methods) options.methods = {}
options.methods[key] = call(path)
})
} | javascript | {
"resource": ""
} |
q26972 | fixAnchors | train | function fixAnchors (hook) {
hook.afterEach(function (html, next) {
// find all headings and replace them
html = html.replace(/<(h\d).+?<\/\1>/g, function (html) {
// create temp node
var div = document.createElement('div')
div.innerHTML = html
// get anchor
var link = div.qu... | javascript | {
"resource": ""
} |
q26973 | train | function(context) {
const androidHome = process.env['ANDROID_HOME']
const hasAndroidEnv = !context.strings.isBlank(androidHome)
const hasAndroid = hasAndroidEnv && context.filesystem.exists(`${androidHome}/tools`) === 'dir'
return Boolean(hasAndroid)
} | javascript | {
"resource": ""
} | |
q26974 | restoreService | train | function restoreService(service) {
if (services[service]) {
restoreAllMethods(service);
if (services[service].stub)
services[service].stub.restore();
delete services[service];
} else {
console.log('Service ' + service + ' was never instantiated yet you try to restore it.');
}
} | javascript | {
"resource": ""
} |
q26975 | copyReadmeFiles | train | function copyReadmeFiles() {
const resolvedSrcReadmePaths = path.resolve(rootDir, srcReadmePaths);
glob(resolvedSrcReadmePaths, void(0), function(error, files) {
files.forEach((filePath) => {
const destReadmePath = filePath.replace(/(\bsrc\b)(?!.*\1)/, destDir);
fs.copyFileSync(file... | javascript | {
"resource": ""
} |
q26976 | execute | train | function execute() {
if (dryRun) {
console.log(`In ${destDir}, this script would...`);
} else {
console.log(`Generating API documentation using TypeDoc...`);
}
const packages = path.resolve(rootDir, srcDir);
glob(packages, {realpath:true}, function(error, srcFiles) {
... | javascript | {
"resource": ""
} |
q26977 | addHeaderToReadme | train | function addHeaderToReadme(packageName) {
const readmePath = path.join(destDir, packageName, 'api', 'README.md');
const readmeText = fs.readFileSync(readmePath).toString();
var docusaurusHeader =
`---\n` +
`id: index\n` +
`---\n\n`;
try {
fs.writeFileSync(readmePath, docusaurusH... | javascript | {
"resource": ""
} |
q26978 | addAPILinkToReadme | train | function addAPILinkToReadme(packageName) {
var readmePath = path.join(destDir, packageName, 'README.md');
var apiLink = "api";
var usageText =
"\n" +
`[API Reference](${apiLink})`;
fs.appendFile(readmePath, usageText, function (err) {
if (err) {
console.log(chalk... | javascript | {
"resource": ""
} |
q26979 | createDirectory | train | function createDirectory(dir) {
if (!fs.existsSync(dir)) {
dryRun ? console.log(`...CREATE the '${dir}' folder.`) : fs.mkdirSync(dir);
}
} | javascript | {
"resource": ""
} |
q26980 | exportReadme | train | function exportReadme(readmePath) {
const readmePaths = path.resolve(process.cwd(), srcDir);
glob(readmePaths, void(0), function(error, files) {
files.forEach((filePath) => {
let documentation = startFile;
const markdown = fs.readFileSync(filePath, "utf8");
const exp... | javascript | {
"resource": ""
} |
q26981 | cleanPath | train | function cleanPath(cleanPath) {
const removePath = path.resolve(process.cwd(), cleanPath)
rimraf(removePath, () => {
console.log(removePath, "cleaned");
});
} | javascript | {
"resource": ""
} |
q26982 | copySchemaFiles | train | function copySchemaFiles() {
const resolvedSrcSchemaPaths = path.resolve(rootDir, srcSchemaPaths);
glob(resolvedSrcSchemaPaths, void(0), function(error, files) {
files.forEach((filePath) => {
const destSchemaPath = filePath.replace(/(\bsrc\b)(?!.*\1)/, destDir);
fs.copyFileSync(file... | javascript | {
"resource": ""
} |
q26983 | js | train | function js(prefix) {
gulp.src('src/clockpicker.js')
.pipe(rename({
prefix: prefix + '-'
}))
.pipe(replace(versionRegExp, version))
.pipe(gulp.dest('dist'))
.pipe(uglify({
preserveComments: 'some'
}))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('dist'));
} | javascript | {
"resource": ""
} |
q26984 | css | train | function css(prefix) {
var stream;
if (prefix === 'bootstrap') {
stream = gulp.src('src/clockpicker.css');
} else {
// Concat with some styles picked from bootstrap
stream = gulp.src(['src/standalone.css', 'src/clockpicker.css'])
.pipe(concat('clockpicker.css'));
}
stream.pipe(rename({
prefix: prefix +... | javascript | {
"resource": ""
} |
q26985 | train | function (layer, targetCenter, targetZoom) {
map._stop();
var startZoom = map._zoom;
targetCenter = L.latLng(targetCenter);
targetZoom = targetZoom === undefined ? startZoom : targetZoom;
targetZoom... | javascript | {
"resource": ""
} | |
q26986 | addDebugLayers | train | function addDebugLayers (node, tree) {
for (let layer in node) {
let counts = node[layer];
addLayerDebugEntry(tree, layer, counts.features, counts.geoms, counts.styles, counts.base);
if (counts.layers) {
tree[layer].layers = tree[layer].layers || {};
addDebugLayers(co... | javascript | {
"resource": ""
} |
q26987 | meshSetString | train | function meshSetString (tiles) {
return JSON.stringify(
Object.entries(tiles).map(([,t]) => {
return Object.entries(t.meshes).map(([,s]) => {
return s.map(m => m.created_at);
});
})
);
} | javascript | {
"resource": ""
} |
q26988 | getCentroidFeatureForPolygon | train | function getCentroidFeatureForPolygon (coordinates, properties, newProperties) {
let centroid = Geo.centroid(coordinates);
if (!centroid) {
return;
}
// clone properties and mixix newProperties
let centroid_properties = {};
Object.assign(centroid_properties, properties, newProperties);
... | javascript | {
"resource": ""
} |
q26989 | flattenProperties | train | function flattenProperties (obj, prefix = null, globals = {}) {
prefix = prefix ? (prefix + '.') : 'global.';
for (const p in obj) {
const key = prefix + p;
const val = obj[p];
globals[key] = val;
if (typeof val === 'object' && !Array.isArray(val)) {
flattenProperti... | javascript | {
"resource": ""
} |
q26990 | compareArray | train | function compareArray(a1, a2) {
if (a1.length != a2.length) return false;
for (var i = 0; i < a1.length; i++) {
if (a1[i] !== a2[i]) return false;
}
return true;
} | javascript | {
"resource": ""
} |
q26991 | unbindKey | train | function unbindKey(key, scope) {
var multipleKeys, keys,
mods = [],
i, j, obj;
multipleKeys = getKeys(key);
for (j = 0; j < multipleKeys.length; j++) {
keys = multipleKeys[j].split('+');
if (keys.length > 1) {
mods = getMods(keys);
key = keys[keys.length - 1];
... | javascript | {
"resource": ""
} |
q26992 | deleteScope | train | function deleteScope(scope){
var key, handlers, i;
for (key in _handlers) {
handlers = _handlers[key];
for (i = 0; i < handlers.length; ) {
if (handlers[i].scope === scope) handlers.splice(i, 1);
else i++;
}
}
} | javascript | {
"resource": ""
} |
q26993 | getKeys | train | function getKeys(key) {
var keys;
key = key.replace(/\s/g, '');
keys = key.split(',');
if ((keys[keys.length - 1]) == '') {
keys[keys.length - 2] += ',';
}
return keys;
} | javascript | {
"resource": ""
} |
q26994 | getMods | train | function getMods(key) {
var mods = key.slice(0, key.length - 1);
for (var mi = 0; mi < mods.length; mi++)
mods[mi] = _MODIFIERS[mods[mi]];
return mods;
} | javascript | {
"resource": ""
} |
q26995 | freeTransferables | train | function freeTransferables(transferables) {
if (!Array.isArray(transferables)) {
return;
}
transferables.filter(t => t.parent && t.property).forEach(t => delete t.parent[t.property]);
} | javascript | {
"resource": ""
} |
q26996 | onHover | train | function onHover (selection) {
var feature = selection.feature;
if (feature) {
if (selection.changed) {
var info;
if (scene.introspection) {
info = getFeaturePropsHTML(feature);
}
else {
v... | javascript | {
"resource": ""
} |
q26997 | getFeaturePropsHTML | train | function getFeaturePropsHTML (feature) {
var props = ['name', 'kind', 'kind_detail', 'id']; // show these properties first if available
Object.keys(feature.properties) // show rest of proeprties alphabetized
.sort()
.forEach(function(p) {
if (props.indexOf(p) === ... | javascript | {
"resource": ""
} |
q26998 | getNextNonBoundarySegment | train | function getNextNonBoundarySegment (line, startIndex, tolerance) {
var endIndex = startIndex;
while (line[endIndex + 1] && outsideTile(line[endIndex], line[endIndex + 1], tolerance)) {
endIndex++;
}
// If there is a line segment remaining that is within the tile, push it to the lines array
... | javascript | {
"resource": ""
} |
q26999 | endPolygon | train | function endPolygon(coordCurr, normPrev, normNext, join_type, v, context) {
// If polygon ends on a tile boundary, don't add a join
if (isCoordOutsideTile(coordCurr)) {
addVertex(coordCurr, normPrev, normPrev, 1, v, context, 1);
addVertex(coordCurr, normPrev, normPrev, 0, v, context, -1);
... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.