repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
matrix-org/matrix-js-sdk | src/store/indexeddb-local-backend.js | LocalIndexedDBStoreBackend | function LocalIndexedDBStoreBackend(
indexedDBInterface, dbName,
) {
this.indexedDB = indexedDBInterface;
this._dbName = "matrix-js-sdk:" + (dbName || "default");
this.db = null;
this._disconnected = true;
this._syncAccumulator = new SyncAccumulator();
this._isNewlyCreated = false;
} | javascript | function LocalIndexedDBStoreBackend(
indexedDBInterface, dbName,
) {
this.indexedDB = indexedDBInterface;
this._dbName = "matrix-js-sdk:" + (dbName || "default");
this.db = null;
this._disconnected = true;
this._syncAccumulator = new SyncAccumulator();
this._isNewlyCreated = false;
} | [
"function",
"LocalIndexedDBStoreBackend",
"(",
"indexedDBInterface",
",",
"dbName",
",",
")",
"{",
"this",
".",
"indexedDB",
"=",
"indexedDBInterface",
";",
"this",
".",
"_dbName",
"=",
"\"matrix-js-sdk:\"",
"+",
"(",
"dbName",
"||",
"\"default\"",
")",
";",
"th... | Does the actual reading from and writing to the indexeddb
Construct a new Indexed Database store backend. This requires a call to
<code>connect()</code> before this store can be used.
@constructor
@param {Object} indexedDBInterface The Indexed DB interface e.g
<code>window.indexedDB</code>
@param {string=} dbName Opti... | [
"Does",
"the",
"actual",
"reading",
"from",
"and",
"writing",
"to",
"the",
"indexeddb"
] | ee8a4698a94a4a6bfaded61d6108492a04aa0d4e | https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/indexeddb-local-backend.js#L125-L134 | train |
matrix-org/matrix-js-sdk | src/store/indexeddb-local-backend.js | function() {
if (!this._disconnected) {
console.log(
`LocalIndexedDBStoreBackend.connect: already connected or connecting`,
);
return Promise.resolve();
}
this._disconnected = false;
console.log(
`LocalIndexedDBStoreBacken... | javascript | function() {
if (!this._disconnected) {
console.log(
`LocalIndexedDBStoreBackend.connect: already connected or connecting`,
);
return Promise.resolve();
}
this._disconnected = false;
console.log(
`LocalIndexedDBStoreBacken... | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_disconnected",
")",
"{",
"console",
".",
"log",
"(",
"`",
"`",
",",
")",
";",
"return",
"Promise",
".",
"resolve",
"(",
")",
";",
"}",
"this",
".",
"_disconnected",
"=",
"false",
";",
"con... | Attempt to connect to the database. This can fail if the user does not
grant permission.
@return {Promise} Resolves if successfully connected. | [
"Attempt",
"to",
"connect",
"to",
"the",
"database",
".",
"This",
"can",
"fail",
"if",
"the",
"user",
"does",
"not",
"grant",
"permission",
"."
] | ee8a4698a94a4a6bfaded61d6108492a04aa0d4e | https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/indexeddb-local-backend.js#L147-L203 | train | |
matrix-org/matrix-js-sdk | src/store/indexeddb-local-backend.js | function() {
return Promise.all([
this._loadAccountData(),
this._loadSyncData(),
]).then(([accountData, syncData]) => {
console.log(
`LocalIndexedDBStoreBackend: loaded initial data`,
);
this._syncAccumulator.accumulate({
... | javascript | function() {
return Promise.all([
this._loadAccountData(),
this._loadSyncData(),
]).then(([accountData, syncData]) => {
console.log(
`LocalIndexedDBStoreBackend: loaded initial data`,
);
this._syncAccumulator.accumulate({
... | [
"function",
"(",
")",
"{",
"return",
"Promise",
".",
"all",
"(",
"[",
"this",
".",
"_loadAccountData",
"(",
")",
",",
"this",
".",
"_loadSyncData",
"(",
")",
",",
"]",
")",
".",
"then",
"(",
"(",
"[",
"accountData",
",",
"syncData",
"]",
")",
"=>",... | Having connected, load initial data from the database and prepare for use
@return {Promise} Resolves on success | [
"Having",
"connected",
"load",
"initial",
"data",
"from",
"the",
"database",
"and",
"prepare",
"for",
"use"
] | ee8a4698a94a4a6bfaded61d6108492a04aa0d4e | https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/indexeddb-local-backend.js#L213-L230 | train | |
matrix-org/matrix-js-sdk | src/store/indexeddb-local-backend.js | function(roomId) {
return new Promise((resolve, reject) =>{
const tx = this.db.transaction(["oob_membership_events"], "readonly");
const store = tx.objectStore("oob_membership_events");
const roomIndex = store.index("room");
const range = IDBKeyRange.only(roomId);... | javascript | function(roomId) {
return new Promise((resolve, reject) =>{
const tx = this.db.transaction(["oob_membership_events"], "readonly");
const store = tx.objectStore("oob_membership_events");
const roomIndex = store.index("room");
const range = IDBKeyRange.only(roomId);... | [
"function",
"(",
"roomId",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"tx",
"=",
"this",
".",
"db",
".",
"transaction",
"(",
"[",
"\"oob_membership_events\"",
"]",
",",
"\"readonly\"",
")",
";",
"... | Returns the out-of-band membership events for this room that
were previously loaded.
@param {string} roomId
@returns {Promise<event[]>} the events, potentially an empty array if OOB loading didn't yield any new members
@returns {null} in case the members for this room haven't been stored yet | [
"Returns",
"the",
"out",
"-",
"of",
"-",
"band",
"membership",
"events",
"for",
"this",
"room",
"that",
"were",
"previously",
"loaded",
"."
] | ee8a4698a94a4a6bfaded61d6108492a04aa0d4e | https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/indexeddb-local-backend.js#L239-L280 | train | |
matrix-org/matrix-js-sdk | src/store/indexeddb-local-backend.js | async function(roomId, membershipEvents) {
console.log(`LL: backend about to store ${membershipEvents.length}` +
` members for ${roomId}`);
const tx = this.db.transaction(["oob_membership_events"], "readwrite");
const store = tx.objectStore("oob_membership_events");
membershi... | javascript | async function(roomId, membershipEvents) {
console.log(`LL: backend about to store ${membershipEvents.length}` +
` members for ${roomId}`);
const tx = this.db.transaction(["oob_membership_events"], "readwrite");
const store = tx.objectStore("oob_membership_events");
membershi... | [
"async",
"function",
"(",
"roomId",
",",
"membershipEvents",
")",
"{",
"console",
".",
"log",
"(",
"`",
"${",
"membershipEvents",
".",
"length",
"}",
"`",
"+",
"`",
"${",
"roomId",
"}",
"`",
")",
";",
"const",
"tx",
"=",
"this",
".",
"db",
".",
"tr... | Stores the out-of-band membership events for this room. Note that
it still makes sense to store an empty array as the OOB status for the room is
marked as fetched, and getOutOfBandMembers will return an empty array instead of null
@param {string} roomId
@param {event[]} membershipEvents the membership events to store | [
"Stores",
"the",
"out",
"-",
"of",
"-",
"band",
"membership",
"events",
"for",
"this",
"room",
".",
"Note",
"that",
"it",
"still",
"makes",
"sense",
"to",
"store",
"an",
"empty",
"array",
"as",
"the",
"OOB",
"status",
"for",
"the",
"room",
"is",
"marke... | ee8a4698a94a4a6bfaded61d6108492a04aa0d4e | https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/indexeddb-local-backend.js#L289-L310 | train | |
matrix-org/matrix-js-sdk | src/store/indexeddb-local-backend.js | function() {
return new Promise((resolve, reject) => {
console.log(`Removing indexeddb instance: ${this._dbName}`);
const req = this.indexedDB.deleteDatabase(this._dbName);
req.onblocked = () => {
console.log(
`can't yet delete indexeddb $... | javascript | function() {
return new Promise((resolve, reject) => {
console.log(`Removing indexeddb instance: ${this._dbName}`);
const req = this.indexedDB.deleteDatabase(this._dbName);
req.onblocked = () => {
console.log(
`can't yet delete indexeddb $... | [
"function",
"(",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"console",
".",
"log",
"(",
"`",
"${",
"this",
".",
"_dbName",
"}",
"`",
")",
";",
"const",
"req",
"=",
"this",
".",
"indexedDB",
".",
"del... | Clear the entire database. This should be used when logging out of a client
to prevent mixing data between accounts.
@return {Promise} Resolved when the database is cleared. | [
"Clear",
"the",
"entire",
"database",
".",
"This",
"should",
"be",
"used",
"when",
"logging",
"out",
"of",
"a",
"client",
"to",
"prevent",
"mixing",
"data",
"between",
"accounts",
"."
] | ee8a4698a94a4a6bfaded61d6108492a04aa0d4e | https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/indexeddb-local-backend.js#L355-L382 | train | |
matrix-org/matrix-js-sdk | src/store/indexeddb-local-backend.js | function(accountData) {
return Promise.try(() => {
const txn = this.db.transaction(["accountData"], "readwrite");
const store = txn.objectStore("accountData");
for (let i = 0; i < accountData.length; i++) {
store.put(accountData[i]); // put == UPSERT
... | javascript | function(accountData) {
return Promise.try(() => {
const txn = this.db.transaction(["accountData"], "readwrite");
const store = txn.objectStore("accountData");
for (let i = 0; i < accountData.length; i++) {
store.put(accountData[i]); // put == UPSERT
... | [
"function",
"(",
"accountData",
")",
"{",
"return",
"Promise",
".",
"try",
"(",
"(",
")",
"=>",
"{",
"const",
"txn",
"=",
"this",
".",
"db",
".",
"transaction",
"(",
"[",
"\"accountData\"",
"]",
",",
"\"readwrite\"",
")",
";",
"const",
"store",
"=",
... | Persist a list of account data events. Events with the same 'type' will
be replaced.
@param {Object[]} accountData An array of raw user-scoped account data events
@return {Promise} Resolves if the events were persisted. | [
"Persist",
"a",
"list",
"of",
"account",
"data",
"events",
".",
"Events",
"with",
"the",
"same",
"type",
"will",
"be",
"replaced",
"."
] | ee8a4698a94a4a6bfaded61d6108492a04aa0d4e | https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/indexeddb-local-backend.js#L457-L466 | train | |
matrix-org/matrix-js-sdk | src/store/indexeddb-local-backend.js | function() {
console.log(
`LocalIndexedDBStoreBackend: loading account data...`,
);
return Promise.try(() => {
const txn = this.db.transaction(["accountData"], "readonly");
const store = txn.objectStore("accountData");
return selectQuery(store, und... | javascript | function() {
console.log(
`LocalIndexedDBStoreBackend: loading account data...`,
);
return Promise.try(() => {
const txn = this.db.transaction(["accountData"], "readonly");
const store = txn.objectStore("accountData");
return selectQuery(store, und... | [
"function",
"(",
")",
"{",
"console",
".",
"log",
"(",
"`",
"`",
",",
")",
";",
"return",
"Promise",
".",
"try",
"(",
"(",
")",
"=>",
"{",
"const",
"txn",
"=",
"this",
".",
"db",
".",
"transaction",
"(",
"[",
"\"accountData\"",
"]",
",",
"\"reado... | Load all the account data events from the database. This is not cached.
@return {Promise<Object[]>} A list of raw global account events. | [
"Load",
"all",
"the",
"account",
"data",
"events",
"from",
"the",
"database",
".",
"This",
"is",
"not",
"cached",
"."
] | ee8a4698a94a4a6bfaded61d6108492a04aa0d4e | https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/indexeddb-local-backend.js#L510-L526 | train | |
matrix-org/matrix-js-sdk | src/store/indexeddb-local-backend.js | function() {
console.log(
`LocalIndexedDBStoreBackend: loading sync data...`,
);
return Promise.try(() => {
const txn = this.db.transaction(["sync"], "readonly");
const store = txn.objectStore("sync");
return selectQuery(store, undefined, (cursor) ... | javascript | function() {
console.log(
`LocalIndexedDBStoreBackend: loading sync data...`,
);
return Promise.try(() => {
const txn = this.db.transaction(["sync"], "readonly");
const store = txn.objectStore("sync");
return selectQuery(store, undefined, (cursor) ... | [
"function",
"(",
")",
"{",
"console",
".",
"log",
"(",
"`",
"`",
",",
")",
";",
"return",
"Promise",
".",
"try",
"(",
"(",
")",
"=>",
"{",
"const",
"txn",
"=",
"this",
".",
"db",
".",
"transaction",
"(",
"[",
"\"sync\"",
"]",
",",
"\"readonly\"",... | Load the sync data from the database.
@return {Promise<Object>} An object with "roomsData" and "nextBatch" keys. | [
"Load",
"the",
"sync",
"data",
"from",
"the",
"database",
"."
] | ee8a4698a94a4a6bfaded61d6108492a04aa0d4e | https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/indexeddb-local-backend.js#L532-L551 | train | |
plotly/react-chart-editor | src/lib/walkObject.js | _walkObject | function _walkObject(object, callback, path, config) {
const {walkArrays, walkArraysMatchingKeys} = config;
Object.keys(object).forEach(key => {
// Callback can force traversal to stop by returning `true`.
if (callback(key, object, path.get(object, key))) {
return;
}
const value = object[key]... | javascript | function _walkObject(object, callback, path, config) {
const {walkArrays, walkArraysMatchingKeys} = config;
Object.keys(object).forEach(key => {
// Callback can force traversal to stop by returning `true`.
if (callback(key, object, path.get(object, key))) {
return;
}
const value = object[key]... | [
"function",
"_walkObject",
"(",
"object",
",",
"callback",
",",
"path",
",",
"config",
")",
"{",
"const",
"{",
"walkArrays",
",",
"walkArraysMatchingKeys",
"}",
"=",
"config",
";",
"Object",
".",
"keys",
"(",
"object",
")",
".",
"forEach",
"(",
"key",
"=... | The function that walkObject calls at each node.
@callback walkObjectCallback
@param {string|number} key The current key, which may be nested.
@param {object} parent The object which owns the 'key' as a prop.
@param {Array} path The keys that lead to the 'parent' object.
@returns {boolean} True if the value at 'key' s... | [
"The",
"function",
"that",
"walkObject",
"calls",
"at",
"each",
"node",
"."
] | 584b6b94237f1f22597025fd8b5d8f69d49bef95 | https://github.com/plotly/react-chart-editor/blob/584b6b94237f1f22597025fd8b5d8f69d49bef95/src/lib/walkObject.js#L129-L142 | train |
sindresorhus/execa | index.js | handleEscaping | function handleEscaping(tokens, token, index) {
if (index === 0) {
return [token];
}
const previousToken = tokens[index - 1];
if (!previousToken.endsWith('\\')) {
return [...tokens, token];
}
return [...tokens.slice(0, index - 1), `${previousToken.slice(0, -1)} ${token}`];
} | javascript | function handleEscaping(tokens, token, index) {
if (index === 0) {
return [token];
}
const previousToken = tokens[index - 1];
if (!previousToken.endsWith('\\')) {
return [...tokens, token];
}
return [...tokens.slice(0, index - 1), `${previousToken.slice(0, -1)} ${token}`];
} | [
"function",
"handleEscaping",
"(",
"tokens",
",",
"token",
",",
"index",
")",
"{",
"if",
"(",
"index",
"===",
"0",
")",
"{",
"return",
"[",
"token",
"]",
";",
"}",
"const",
"previousToken",
"=",
"tokens",
"[",
"index",
"-",
"1",
"]",
";",
"if",
"("... | Allow spaces to be escaped by a backslash if not meant as a delimiter | [
"Allow",
"spaces",
"to",
"be",
"escaped",
"by",
"a",
"backslash",
"if",
"not",
"meant",
"as",
"a",
"delimiter"
] | 659f4444795c8c20c5b4ef61c8b9d744136604c0 | https://github.com/sindresorhus/execa/blob/659f4444795c8c20c5b4ef61c8b9d744136604c0/index.js#L21-L33 | train |
ampproject/ampstart | webpack.config.js | isEnv | function isEnv(envAlias) {
// Check for default case
if (envAlias === ENV_ALIAS.DEV && Object.keys(env).length === 0) {
return true;
}
return envAlias.some(alias => env[alias]);
} | javascript | function isEnv(envAlias) {
// Check for default case
if (envAlias === ENV_ALIAS.DEV && Object.keys(env).length === 0) {
return true;
}
return envAlias.some(alias => env[alias]);
} | [
"function",
"isEnv",
"(",
"envAlias",
")",
"{",
"// Check for default case",
"if",
"(",
"envAlias",
"===",
"ENV_ALIAS",
".",
"DEV",
"&&",
"Object",
".",
"keys",
"(",
"env",
")",
".",
"length",
"===",
"0",
")",
"{",
"return",
"true",
";",
"}",
"return",
... | Function to return if the environment matched the environment alias | [
"Function",
"to",
"return",
"if",
"the",
"environment",
"matched",
"the",
"environment",
"alias"
] | 40c3d7750f3406ab3e73cf0b31e99987dfd89506 | https://github.com/ampproject/ampstart/blob/40c3d7750f3406ab3e73cf0b31e99987dfd89506/webpack.config.js#L33-L40 | train |
ampproject/ampstart | functions/index.js | cors | function cors(req, res, next) {
const port = process.env.NODE_ENV === 'production'
? null
: new url.URL(req.query.__amp_source_origin).port;
const host = process.env.NODE_ENV === 'production'
? `https://${req.hostname}`
: `http://${req.hostname}:${port}`;
res.header('amp-access-control-allow-sou... | javascript | function cors(req, res, next) {
const port = process.env.NODE_ENV === 'production'
? null
: new url.URL(req.query.__amp_source_origin).port;
const host = process.env.NODE_ENV === 'production'
? `https://${req.hostname}`
: `http://${req.hostname}:${port}`;
res.header('amp-access-control-allow-sou... | [
"function",
"cors",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"const",
"port",
"=",
"process",
".",
"env",
".",
"NODE_ENV",
"===",
"'production'",
"?",
"null",
":",
"new",
"url",
".",
"URL",
"(",
"req",
".",
"query",
".",
"__amp_source_origin",
... | cors is HTTP middleware that sets an AMP-specific cross origin resource
sharing HTTP header on our response.
@param {Object} req - The HTTP request object.
@param {Object} res - The HTTP response object.
@param {Function} next - The next HTTP handler to execute. | [
"cors",
"is",
"HTTP",
"middleware",
"that",
"sets",
"an",
"AMP",
"-",
"specific",
"cross",
"origin",
"resource",
"sharing",
"HTTP",
"header",
"on",
"our",
"response",
"."
] | 40c3d7750f3406ab3e73cf0b31e99987dfd89506 | https://github.com/ampproject/ampstart/blob/40c3d7750f3406ab3e73cf0b31e99987dfd89506/functions/index.js#L19-L31 | train |
ampproject/ampstart | functions/index.js | filter | function filter(data, query) {
var results = [];
var push = true;
// omit every result that doesn't pass _every_ filter
data.forEach((val) => {
var push = true;
// if we fail a filter condition, then don't push
// check if we're over the max price
if (query.maxPrice > 0) {
if (val.price.... | javascript | function filter(data, query) {
var results = [];
var push = true;
// omit every result that doesn't pass _every_ filter
data.forEach((val) => {
var push = true;
// if we fail a filter condition, then don't push
// check if we're over the max price
if (query.maxPrice > 0) {
if (val.price.... | [
"function",
"filter",
"(",
"data",
",",
"query",
")",
"{",
"var",
"results",
"=",
"[",
"]",
";",
"var",
"push",
"=",
"true",
";",
"// omit every result that doesn't pass _every_ filter",
"data",
".",
"forEach",
"(",
"(",
"val",
")",
"=>",
"{",
"var",
"push... | filter returns the travel data that matches the given query.
@param {Array} data - Array of objects containing the travel data to
filter.
@param {Object} query - An HTTP request query object.
@return {Array} - An array of travelData objects. | [
"filter",
"returns",
"the",
"travel",
"data",
"that",
"matches",
"the",
"given",
"query",
"."
] | 40c3d7750f3406ab3e73cf0b31e99987dfd89506 | https://github.com/ampproject/ampstart/blob/40c3d7750f3406ab3e73cf0b31e99987dfd89506/functions/index.js#L61-L105 | train |
ampproject/ampstart | functions/index.js | selectedCities | function selectedCities(travelData, cities) {
var selected = [];
travelData.activities.forEach((data) => {
const isSelected = cities.includes(data.location.city);
// check if the city already exists in our cities array
var existsIdx = -1;
selected.forEach((city, idx) => {
if (city.name === da... | javascript | function selectedCities(travelData, cities) {
var selected = [];
travelData.activities.forEach((data) => {
const isSelected = cities.includes(data.location.city);
// check if the city already exists in our cities array
var existsIdx = -1;
selected.forEach((city, idx) => {
if (city.name === da... | [
"function",
"selectedCities",
"(",
"travelData",
",",
"cities",
")",
"{",
"var",
"selected",
"=",
"[",
"]",
";",
"travelData",
".",
"activities",
".",
"forEach",
"(",
"(",
"data",
")",
"=>",
"{",
"const",
"isSelected",
"=",
"cities",
".",
"includes",
"("... | Checks to see if any the given cities exist in our travel data,
returning all the ones that are.
@param {Array} travelData - Array of objects containing the travel data to
filter.
@param {Array} cities - Array of strings containing city names.
@return {Array} The selected cities. | [
"Checks",
"to",
"see",
"if",
"any",
"the",
"given",
"cities",
"exist",
"in",
"our",
"travel",
"data",
"returning",
"all",
"the",
"ones",
"that",
"are",
"."
] | 40c3d7750f3406ab3e73cf0b31e99987dfd89506 | https://github.com/ampproject/ampstart/blob/40c3d7750f3406ab3e73cf0b31e99987dfd89506/functions/index.js#L116-L148 | train |
ampproject/ampstart | functions/index.js | sortResults | function sortResults(val, results) {
const sortPopularity = (a, b) => {
if (a.reviews.count < b.reviews.count) {
return 1;
} else if (a.reviews.count > b.reviews.count) {
return -1;
}
return 0;
};
const sortRating = (a, b) => {
if (a.reviews.averageRating.value < b.reviews.average... | javascript | function sortResults(val, results) {
const sortPopularity = (a, b) => {
if (a.reviews.count < b.reviews.count) {
return 1;
} else if (a.reviews.count > b.reviews.count) {
return -1;
}
return 0;
};
const sortRating = (a, b) => {
if (a.reviews.averageRating.value < b.reviews.average... | [
"function",
"sortResults",
"(",
"val",
",",
"results",
")",
"{",
"const",
"sortPopularity",
"=",
"(",
"a",
",",
"b",
")",
"=>",
"{",
"if",
"(",
"a",
".",
"reviews",
".",
"count",
"<",
"b",
".",
"reviews",
".",
"count",
")",
"{",
"return",
"1",
";... | sortResults checks to see if the value is one of the parameters we
know how to sort by.
@param {String} val - The value to check.
@param {Array} results - Array of object to sort.
@return {Array} The sorted results. | [
"sortResults",
"checks",
"to",
"see",
"if",
"the",
"value",
"is",
"one",
"of",
"the",
"parameters",
"we",
"know",
"how",
"to",
"sort",
"by",
"."
] | 40c3d7750f3406ab3e73cf0b31e99987dfd89506 | https://github.com/ampproject/ampstart/blob/40c3d7750f3406ab3e73cf0b31e99987dfd89506/functions/index.js#L158-L214 | train |
ampproject/ampstart | functions/index.js | getSVGGraphPathData | function getSVGGraphPathData(data, width, height) {
var max = Math.max.apply(null, data);
var width = 800;
var height = 100;
var scaleH = width / (data.length - 1)
var scaleV = height / max;
var factor = 0.25;
var commands = [`m0,${applyScaleV(data[0])}`];
function round(val) {
return Math.round... | javascript | function getSVGGraphPathData(data, width, height) {
var max = Math.max.apply(null, data);
var width = 800;
var height = 100;
var scaleH = width / (data.length - 1)
var scaleV = height / max;
var factor = 0.25;
var commands = [`m0,${applyScaleV(data[0])}`];
function round(val) {
return Math.round... | [
"function",
"getSVGGraphPathData",
"(",
"data",
",",
"width",
",",
"height",
")",
"{",
"var",
"max",
"=",
"Math",
".",
"max",
".",
"apply",
"(",
"null",
",",
"data",
")",
";",
"var",
"width",
"=",
"800",
";",
"var",
"height",
"=",
"100",
";",
"var"... | getSVGGraphPath data converts an array of numbers to valid SVG graph path
data.
@param {Array} data - The data to convert to SVG graph path format.
@param {Integer} width - The width of the SVG.
@param {Integer} height - The height of the SVG.
@return {String} The string representing the SVG path. | [
"getSVGGraphPath",
"data",
"converts",
"an",
"array",
"of",
"numbers",
"to",
"valid",
"SVG",
"graph",
"path",
"data",
"."
] | 40c3d7750f3406ab3e73cf0b31e99987dfd89506 | https://github.com/ampproject/ampstart/blob/40c3d7750f3406ab3e73cf0b31e99987dfd89506/functions/index.js#L308-L349 | train |
ampproject/ampstart | www/configurator/src/index.js | handleHashChange_ | function handleHashChange_() {
cssTranspiler.getCssWithVars(getUrlCssVars()).then(updatedStyles => {
iframeManager.setStyle(updatedStyles);
}).catch(error => {
// Don't set the styles, log the error
console.error(error);
});
} | javascript | function handleHashChange_() {
cssTranspiler.getCssWithVars(getUrlCssVars()).then(updatedStyles => {
iframeManager.setStyle(updatedStyles);
}).catch(error => {
// Don't set the styles, log the error
console.error(error);
});
} | [
"function",
"handleHashChange_",
"(",
")",
"{",
"cssTranspiler",
".",
"getCssWithVars",
"(",
"getUrlCssVars",
"(",
")",
")",
".",
"then",
"(",
"updatedStyles",
"=>",
"{",
"iframeManager",
".",
"setStyle",
"(",
"updatedStyles",
")",
";",
"}",
")",
".",
"catch... | Function to handle URL hash changes. This is not used until the initialization of the configurator is completed.
Also, this will simply get the latest URL params, pass them to the transpiler, and set the styles in the iframe manager. | [
"Function",
"to",
"handle",
"URL",
"hash",
"changes",
".",
"This",
"is",
"not",
"used",
"until",
"the",
"initialization",
"of",
"the",
"configurator",
"is",
"completed",
".",
"Also",
"this",
"will",
"simply",
"get",
"the",
"latest",
"URL",
"params",
"pass",
... | 40c3d7750f3406ab3e73cf0b31e99987dfd89506 | https://github.com/ampproject/ampstart/blob/40c3d7750f3406ab3e73cf0b31e99987dfd89506/www/configurator/src/index.js#L92-L99 | train |
clientIO/joint | plugins/layout/ports/joint.layout.port.js | argPoint | function argPoint(bbox, args) {
var x = args.x;
if (util.isString(x)) {
x = parseFloat(x) / 100 * bbox.width;
}
var y = args.y;
if (util.isString(y)) {
y = parseFloat(y) / 100 * bbox.height;
}
return g.point(x || 0, y || 0);
} | javascript | function argPoint(bbox, args) {
var x = args.x;
if (util.isString(x)) {
x = parseFloat(x) / 100 * bbox.width;
}
var y = args.y;
if (util.isString(y)) {
y = parseFloat(y) / 100 * bbox.height;
}
return g.point(x || 0, y || 0);
} | [
"function",
"argPoint",
"(",
"bbox",
",",
"args",
")",
"{",
"var",
"x",
"=",
"args",
".",
"x",
";",
"if",
"(",
"util",
".",
"isString",
"(",
"x",
")",
")",
"{",
"x",
"=",
"parseFloat",
"(",
"x",
")",
"/",
"100",
"*",
"bbox",
".",
"width",
";"... | Creates a point stored in arguments | [
"Creates",
"a",
"point",
"stored",
"in",
"arguments"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/plugins/layout/ports/joint.layout.port.js#L56-L69 | train |
clientIO/joint | plugins/connectors/joint.connectors.jumpover.js | findLineIntersections | function findLineIntersections(line, crossCheckLines) {
return util.toArray(crossCheckLines).reduce(function(res, crossCheckLine) {
var intersection = line.intersection(crossCheckLine);
if (intersection) {
res.push(intersection);
}
return res;
... | javascript | function findLineIntersections(line, crossCheckLines) {
return util.toArray(crossCheckLines).reduce(function(res, crossCheckLine) {
var intersection = line.intersection(crossCheckLine);
if (intersection) {
res.push(intersection);
}
return res;
... | [
"function",
"findLineIntersections",
"(",
"line",
",",
"crossCheckLines",
")",
"{",
"return",
"util",
".",
"toArray",
"(",
"crossCheckLines",
")",
".",
"reduce",
"(",
"function",
"(",
"res",
",",
"crossCheckLine",
")",
"{",
"var",
"intersection",
"=",
"line",
... | Utility function to collect all intersection poinst of a single
line against group of other lines.
@param {g.line} line where to find points
@param {g.line[]} crossCheckLines lines to cross
@return {g.point[]} list of intersection points | [
"Utility",
"function",
"to",
"collect",
"all",
"intersection",
"poinst",
"of",
"a",
"single",
"line",
"against",
"group",
"of",
"other",
"lines",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/plugins/connectors/joint.connectors.jumpover.js#L79-L87 | train |
clientIO/joint | plugins/connectors/joint.connectors.jumpover.js | createJumps | function createJumps(line, intersections, jumpSize) {
return intersections.reduce(function(resultLines, point, idx) {
// skipping points that were merged with the previous line
// to make bigger arc over multiple lines that are close to each other
if (point.skip === true) {
... | javascript | function createJumps(line, intersections, jumpSize) {
return intersections.reduce(function(resultLines, point, idx) {
// skipping points that were merged with the previous line
// to make bigger arc over multiple lines that are close to each other
if (point.skip === true) {
... | [
"function",
"createJumps",
"(",
"line",
",",
"intersections",
",",
"jumpSize",
")",
"{",
"return",
"intersections",
".",
"reduce",
"(",
"function",
"(",
"resultLines",
",",
"point",
",",
"idx",
")",
"{",
"// skipping points that were merged with the previous line",
... | Split input line into multiple based on intersection points.
@param {g.line} line input line to split
@param {g.point[]} intersections poinst where to split the line
@param {number} jumpSize the size of jump arc (length empty spot on a line)
@return {g.line[]} list of lines being split | [
"Split",
"input",
"line",
"into",
"multiple",
"based",
"on",
"intersection",
"points",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/plugins/connectors/joint.connectors.jumpover.js#L106-L161 | train |
clientIO/joint | plugins/routers/joint.routers.manhattan.js | function() {
var step = this.step;
return {
x: -step,
y: -step,
width: 2 * step,
height: 2 * step
};
} | javascript | function() {
var step = this.step;
return {
x: -step,
y: -step,
width: 2 * step,
height: 2 * step
};
} | [
"function",
"(",
")",
"{",
"var",
"step",
"=",
"this",
".",
"step",
";",
"return",
"{",
"x",
":",
"-",
"step",
",",
"y",
":",
"-",
"step",
",",
"width",
":",
"2",
"*",
"step",
",",
"height",
":",
"2",
"*",
"step",
"}",
";",
"}"
] | padding applied on the element bounding boxes | [
"padding",
"applied",
"on",
"the",
"element",
"bounding",
"boxes"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/plugins/routers/joint.routers.manhattan.js#L77-L87 | train | |
clientIO/joint | plugins/routers/joint.routers.manhattan.js | getTargetBBox | function getTargetBBox(linkView, opt) {
// expand by padding box
if (opt && opt.paddingBox) return linkView.targetBBox.clone().moveAndExpand(opt.paddingBox);
return linkView.targetBBox.clone();
} | javascript | function getTargetBBox(linkView, opt) {
// expand by padding box
if (opt && opt.paddingBox) return linkView.targetBBox.clone().moveAndExpand(opt.paddingBox);
return linkView.targetBBox.clone();
} | [
"function",
"getTargetBBox",
"(",
"linkView",
",",
"opt",
")",
"{",
"// expand by padding box",
"if",
"(",
"opt",
"&&",
"opt",
".",
"paddingBox",
")",
"return",
"linkView",
".",
"targetBBox",
".",
"clone",
"(",
")",
".",
"moveAndExpand",
"(",
"opt",
".",
"... | return target bbox | [
"return",
"target",
"bbox"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/plugins/routers/joint.routers.manhattan.js#L276-L282 | train |
clientIO/joint | plugins/routers/joint.routers.manhattan.js | getSourceAnchor | function getSourceAnchor(linkView, opt) {
if (linkView.sourceAnchor) return linkView.sourceAnchor;
// fallback: center of bbox
var sourceBBox = getSourceBBox(linkView, opt);
return sourceBBox.center();
} | javascript | function getSourceAnchor(linkView, opt) {
if (linkView.sourceAnchor) return linkView.sourceAnchor;
// fallback: center of bbox
var sourceBBox = getSourceBBox(linkView, opt);
return sourceBBox.center();
} | [
"function",
"getSourceAnchor",
"(",
"linkView",
",",
"opt",
")",
"{",
"if",
"(",
"linkView",
".",
"sourceAnchor",
")",
"return",
"linkView",
".",
"sourceAnchor",
";",
"// fallback: center of bbox",
"var",
"sourceBBox",
"=",
"getSourceBBox",
"(",
"linkView",
",",
... | return source anchor | [
"return",
"source",
"anchor"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/plugins/routers/joint.routers.manhattan.js#L285-L292 | train |
clientIO/joint | plugins/routers/joint.routers.manhattan.js | getTargetAnchor | function getTargetAnchor(linkView, opt) {
if (linkView.targetAnchor) return linkView.targetAnchor;
// fallback: center of bbox
var targetBBox = getTargetBBox(linkView, opt);
return targetBBox.center(); // default
} | javascript | function getTargetAnchor(linkView, opt) {
if (linkView.targetAnchor) return linkView.targetAnchor;
// fallback: center of bbox
var targetBBox = getTargetBBox(linkView, opt);
return targetBBox.center(); // default
} | [
"function",
"getTargetAnchor",
"(",
"linkView",
",",
"opt",
")",
"{",
"if",
"(",
"linkView",
".",
"targetAnchor",
")",
"return",
"linkView",
".",
"targetAnchor",
";",
"// fallback: center of bbox",
"var",
"targetBBox",
"=",
"getTargetBBox",
"(",
"linkView",
",",
... | return target anchor | [
"return",
"target",
"anchor"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/plugins/routers/joint.routers.manhattan.js#L295-L302 | train |
clientIO/joint | plugins/routers/joint.routers.manhattan.js | getDirectionAngle | function getDirectionAngle(start, end, numDirections, grid, opt) {
var quadrant = 360 / numDirections;
var angleTheta = start.theta(fixAngleEnd(start, end, grid, opt));
var normalizedAngle = g.normalizeAngle(angleTheta + (quadrant / 2));
return quadrant * Math.floor(normalizedAngle / qu... | javascript | function getDirectionAngle(start, end, numDirections, grid, opt) {
var quadrant = 360 / numDirections;
var angleTheta = start.theta(fixAngleEnd(start, end, grid, opt));
var normalizedAngle = g.normalizeAngle(angleTheta + (quadrant / 2));
return quadrant * Math.floor(normalizedAngle / qu... | [
"function",
"getDirectionAngle",
"(",
"start",
",",
"end",
",",
"numDirections",
",",
"grid",
",",
"opt",
")",
"{",
"var",
"quadrant",
"=",
"360",
"/",
"numDirections",
";",
"var",
"angleTheta",
"=",
"start",
".",
"theta",
"(",
"fixAngleEnd",
"(",
"start",... | returns a direction index from start point to end point corrects for grid deformation between start and end | [
"returns",
"a",
"direction",
"index",
"from",
"start",
"point",
"to",
"end",
"point",
"corrects",
"for",
"grid",
"deformation",
"between",
"start",
"and",
"end"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/plugins/routers/joint.routers.manhattan.js#L306-L312 | train |
clientIO/joint | plugins/routers/joint.routers.manhattan.js | getDirectionChange | function getDirectionChange(angle1, angle2) {
var directionChange = Math.abs(angle1 - angle2);
return (directionChange > 180) ? (360 - directionChange) : directionChange;
} | javascript | function getDirectionChange(angle1, angle2) {
var directionChange = Math.abs(angle1 - angle2);
return (directionChange > 180) ? (360 - directionChange) : directionChange;
} | [
"function",
"getDirectionChange",
"(",
"angle1",
",",
"angle2",
")",
"{",
"var",
"directionChange",
"=",
"Math",
".",
"abs",
"(",
"angle1",
"-",
"angle2",
")",
";",
"return",
"(",
"directionChange",
">",
"180",
")",
"?",
"(",
"360",
"-",
"directionChange",... | return the change in direction between two direction angles | [
"return",
"the",
"change",
"in",
"direction",
"between",
"two",
"direction",
"angles"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/plugins/routers/joint.routers.manhattan.js#L336-L340 | train |
clientIO/joint | plugins/routers/joint.routers.manhattan.js | getGridOffsets | function getGridOffsets(directions, grid, opt) {
var step = opt.step;
util.toArray(opt.directions).forEach(function(direction) {
direction.gridOffsetX = (direction.offsetX / step) * grid.x;
direction.gridOffsetY = (direction.offsetY / step) * grid.y;
});
} | javascript | function getGridOffsets(directions, grid, opt) {
var step = opt.step;
util.toArray(opt.directions).forEach(function(direction) {
direction.gridOffsetX = (direction.offsetX / step) * grid.x;
direction.gridOffsetY = (direction.offsetY / step) * grid.y;
});
} | [
"function",
"getGridOffsets",
"(",
"directions",
",",
"grid",
",",
"opt",
")",
"{",
"var",
"step",
"=",
"opt",
".",
"step",
";",
"util",
".",
"toArray",
"(",
"opt",
".",
"directions",
")",
".",
"forEach",
"(",
"function",
"(",
"direction",
")",
"{",
... | fix direction offsets according to current grid | [
"fix",
"direction",
"offsets",
"according",
"to",
"current",
"grid"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/plugins/routers/joint.routers.manhattan.js#L343-L352 | train |
clientIO/joint | plugins/routers/joint.routers.manhattan.js | getGrid | function getGrid(step, source, target) {
return {
source: source.clone(),
x: getGridDimension(target.x - source.x, step),
y: getGridDimension(target.y - source.y, step)
};
} | javascript | function getGrid(step, source, target) {
return {
source: source.clone(),
x: getGridDimension(target.x - source.x, step),
y: getGridDimension(target.y - source.y, step)
};
} | [
"function",
"getGrid",
"(",
"step",
",",
"source",
",",
"target",
")",
"{",
"return",
"{",
"source",
":",
"source",
".",
"clone",
"(",
")",
",",
"x",
":",
"getGridDimension",
"(",
"target",
".",
"x",
"-",
"source",
".",
"x",
",",
"step",
")",
",",
... | get grid size in x and y dimensions, adapted to source and target positions | [
"get",
"grid",
"size",
"in",
"x",
"and",
"y",
"dimensions",
"adapted",
"to",
"source",
"and",
"target",
"positions"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/plugins/routers/joint.routers.manhattan.js#L355-L362 | train |
clientIO/joint | plugins/routers/joint.routers.manhattan.js | snapToGrid | function snapToGrid(point, grid) {
var source = grid.source;
var snappedX = g.snapToGrid(point.x - source.x, grid.x) + source.x;
var snappedY = g.snapToGrid(point.y - source.y, grid.y) + source.y;
return new g.Point(snappedX, snappedY);
} | javascript | function snapToGrid(point, grid) {
var source = grid.source;
var snappedX = g.snapToGrid(point.x - source.x, grid.x) + source.x;
var snappedY = g.snapToGrid(point.y - source.y, grid.y) + source.y;
return new g.Point(snappedX, snappedY);
} | [
"function",
"snapToGrid",
"(",
"point",
",",
"grid",
")",
"{",
"var",
"source",
"=",
"grid",
".",
"source",
";",
"var",
"snappedX",
"=",
"g",
".",
"snapToGrid",
"(",
"point",
".",
"x",
"-",
"source",
".",
"x",
",",
"grid",
".",
"x",
")",
"+",
"so... | return a clone of point snapped to grid | [
"return",
"a",
"clone",
"of",
"point",
"snapped",
"to",
"grid"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/plugins/routers/joint.routers.manhattan.js#L385-L393 | train |
clientIO/joint | plugins/routers/joint.routers.manhattan.js | align | function align(point, grid, precision) {
return round(snapToGrid(point.clone(), grid), precision);
} | javascript | function align(point, grid, precision) {
return round(snapToGrid(point.clone(), grid), precision);
} | [
"function",
"align",
"(",
"point",
",",
"grid",
",",
"precision",
")",
"{",
"return",
"round",
"(",
"snapToGrid",
"(",
"point",
".",
"clone",
"(",
")",
",",
"grid",
")",
",",
"precision",
")",
";",
"}"
] | snap to grid and then round the point | [
"snap",
"to",
"grid",
"and",
"then",
"round",
"the",
"point"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/plugins/routers/joint.routers.manhattan.js#L402-L405 | train |
clientIO/joint | plugins/routers/joint.routers.manhattan.js | normalizePoint | function normalizePoint(point) {
return new g.Point(
point.x === 0 ? 0 : Math.abs(point.x) / point.x,
point.y === 0 ? 0 : Math.abs(point.y) / point.y
);
} | javascript | function normalizePoint(point) {
return new g.Point(
point.x === 0 ? 0 : Math.abs(point.x) / point.x,
point.y === 0 ? 0 : Math.abs(point.y) / point.y
);
} | [
"function",
"normalizePoint",
"(",
"point",
")",
"{",
"return",
"new",
"g",
".",
"Point",
"(",
"point",
".",
"x",
"===",
"0",
"?",
"0",
":",
"Math",
".",
"abs",
"(",
"point",
".",
"x",
")",
"/",
"point",
".",
"x",
",",
"point",
".",
"y",
"===",... | return a normalized vector from given point used to determine the direction of a difference of two points | [
"return",
"a",
"normalized",
"vector",
"from",
"given",
"point",
"used",
"to",
"determine",
"the",
"direction",
"of",
"a",
"difference",
"of",
"two",
"points"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/plugins/routers/joint.routers.manhattan.js#L416-L422 | train |
clientIO/joint | plugins/routers/joint.routers.manhattan.js | estimateCost | function estimateCost(from, endPoints) {
var min = Infinity;
for (var i = 0, len = endPoints.length; i < len; i++) {
var cost = from.manhattanDistance(endPoints[i]);
if (cost < min) min = cost;
}
return min;
} | javascript | function estimateCost(from, endPoints) {
var min = Infinity;
for (var i = 0, len = endPoints.length; i < len; i++) {
var cost = from.manhattanDistance(endPoints[i]);
if (cost < min) min = cost;
}
return min;
} | [
"function",
"estimateCost",
"(",
"from",
",",
"endPoints",
")",
"{",
"var",
"min",
"=",
"Infinity",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"endPoints",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"var",
"cost",... | heuristic method to determine the distance between two points | [
"heuristic",
"method",
"to",
"determine",
"the",
"distance",
"between",
"two",
"points"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/plugins/routers/joint.routers.manhattan.js#L466-L476 | train |
clientIO/joint | plugins/routers/joint.routers.manhattan.js | resolveOptions | function resolveOptions(opt) {
opt.directions = util.result(opt, 'directions');
opt.penalties = util.result(opt, 'penalties');
opt.paddingBox = util.result(opt, 'paddingBox');
opt.padding = util.result(opt, 'padding');
if (opt.padding) {
// if both provided, opt.pad... | javascript | function resolveOptions(opt) {
opt.directions = util.result(opt, 'directions');
opt.penalties = util.result(opt, 'penalties');
opt.paddingBox = util.result(opt, 'paddingBox');
opt.padding = util.result(opt, 'padding');
if (opt.padding) {
// if both provided, opt.pad... | [
"function",
"resolveOptions",
"(",
"opt",
")",
"{",
"opt",
".",
"directions",
"=",
"util",
".",
"result",
"(",
"opt",
",",
"'directions'",
")",
";",
"opt",
".",
"penalties",
"=",
"util",
".",
"result",
"(",
"opt",
",",
"'penalties'",
")",
";",
"opt",
... | resolve some of the options | [
"resolve",
"some",
"of",
"the",
"options"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/plugins/routers/joint.routers.manhattan.js#L725-L750 | train |
clientIO/joint | plugins/routers/joint.routers.manhattan.js | router | function router(vertices, opt, linkView) {
resolveOptions(opt);
// enable/disable linkView perpendicular option
linkView.options.perpendicular = !!opt.perpendicular;
var sourceBBox = getSourceBBox(linkView, opt);
var targetBBox = getTargetBBox(linkView, opt);
var sour... | javascript | function router(vertices, opt, linkView) {
resolveOptions(opt);
// enable/disable linkView perpendicular option
linkView.options.perpendicular = !!opt.perpendicular;
var sourceBBox = getSourceBBox(linkView, opt);
var targetBBox = getTargetBBox(linkView, opt);
var sour... | [
"function",
"router",
"(",
"vertices",
",",
"opt",
",",
"linkView",
")",
"{",
"resolveOptions",
"(",
"opt",
")",
";",
"// enable/disable linkView perpendicular option",
"linkView",
".",
"options",
".",
"perpendicular",
"=",
"!",
"!",
"opt",
".",
"perpendicular",
... | initialization of the route finding | [
"initialization",
"of",
"the",
"route",
"finding"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/plugins/routers/joint.routers.manhattan.js#L753-L822 | train |
clientIO/joint | dist/joint.nowrap.js | TypedArray | function TypedArray(arg1) {
var result;
if (typeof arg1 === 'number') {
result = new Array(arg1);
for (var i = 0; i < arg1; ++i) {
result[i] = 0;
}
} else {
result = arg1.slice(0);
}
result.subarray = subarray;
... | javascript | function TypedArray(arg1) {
var result;
if (typeof arg1 === 'number') {
result = new Array(arg1);
for (var i = 0; i < arg1; ++i) {
result[i] = 0;
}
} else {
result = arg1.slice(0);
}
result.subarray = subarray;
... | [
"function",
"TypedArray",
"(",
"arg1",
")",
"{",
"var",
"result",
";",
"if",
"(",
"typeof",
"arg1",
"===",
"'number'",
")",
"{",
"result",
"=",
"new",
"Array",
"(",
"arg1",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"arg1",
";",
... | we need typed arrays | [
"we",
"need",
"typed",
"arrays"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L98-L118 | train |
clientIO/joint | dist/joint.nowrap.js | function(knots) {
console.warn('deprecated');
var firstControlPoints = [];
var secondControlPoints = [];
var n = knots.length - 1;
var i;
// Special case: Bezier curve should be a straight line.
if (n == 1) {
// 3P1 =... | javascript | function(knots) {
console.warn('deprecated');
var firstControlPoints = [];
var secondControlPoints = [];
var n = knots.length - 1;
var i;
// Special case: Bezier curve should be a straight line.
if (n == 1) {
// 3P1 =... | [
"function",
"(",
"knots",
")",
"{",
"console",
".",
"warn",
"(",
"'deprecated'",
")",
";",
"var",
"firstControlPoints",
"=",
"[",
"]",
";",
"var",
"secondControlPoints",
"=",
"[",
"]",
";",
"var",
"n",
"=",
"knots",
".",
"length",
"-",
"1",
";",
"var... | Get open-ended Bezier Spline Control Points. @deprecated @param knots Input Knot Bezier spline points (At least two points!). @param firstControlPoints Output First Control points. Array of knots.length - 1 length. @param secondControlPoints Output Second Control points. Array of knots.length - 1 length. | [
"Get",
"open",
"-",
"ended",
"Bezier",
"Spline",
"Control",
"Points",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L441-L514 | train | |
clientIO/joint | dist/joint.nowrap.js | function(c) {
return !!c &&
this.start.x === c.start.x &&
this.start.y === c.start.y &&
this.controlPoint1.x === c.controlPoint1.x &&
this.controlPoint1.y === c.controlPoint1.y &&
this.controlPoint2.x === c.... | javascript | function(c) {
return !!c &&
this.start.x === c.start.x &&
this.start.y === c.start.y &&
this.controlPoint1.x === c.controlPoint1.x &&
this.controlPoint1.y === c.controlPoint1.y &&
this.controlPoint2.x === c.... | [
"function",
"(",
"c",
")",
"{",
"return",
"!",
"!",
"c",
"&&",
"this",
".",
"start",
".",
"x",
"===",
"c",
".",
"start",
".",
"x",
"&&",
"this",
".",
"start",
".",
"y",
"===",
"c",
".",
"start",
".",
"y",
"&&",
"this",
".",
"controlPoint1",
"... | Checks whether two curves are exactly the same. | [
"Checks",
"whether",
"two",
"curves",
"are",
"exactly",
"the",
"same",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L1026-L1037 | train | |
clientIO/joint | dist/joint.nowrap.js | function(t) {
var start = this.start;
var control1 = this.controlPoint1;
var control2 = this.controlPoint2;
var end = this.end;
// shortcuts for `t` values that are out of range
if (t <= 0) {
return {
startCont... | javascript | function(t) {
var start = this.start;
var control1 = this.controlPoint1;
var control2 = this.controlPoint2;
var end = this.end;
// shortcuts for `t` values that are out of range
if (t <= 0) {
return {
startCont... | [
"function",
"(",
"t",
")",
"{",
"var",
"start",
"=",
"this",
".",
"start",
";",
"var",
"control1",
"=",
"this",
".",
"controlPoint1",
";",
"var",
"control2",
"=",
"this",
".",
"controlPoint2",
";",
"var",
"end",
"=",
"this",
".",
"end",
";",
"// shor... | Returns five helper points necessary for curve division. | [
"Returns",
"five",
"helper",
"points",
"necessary",
"for",
"curve",
"division",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L1040-L1086 | train | |
clientIO/joint | dist/joint.nowrap.js | function(opt) {
opt = opt || {};
var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision; // opt.precision only used in getSubdivisions() call
var subdivisions = (opt.subdivisions === undefined) ? this.getSubdivisions({ precision: precision }) : opt.subdivisio... | javascript | function(opt) {
opt = opt || {};
var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision; // opt.precision only used in getSubdivisions() call
var subdivisions = (opt.subdivisions === undefined) ? this.getSubdivisions({ precision: precision }) : opt.subdivisio... | [
"function",
"(",
"opt",
")",
"{",
"opt",
"=",
"opt",
"||",
"{",
"}",
";",
"var",
"precision",
"=",
"(",
"opt",
".",
"precision",
"===",
"undefined",
")",
"?",
"this",
".",
"PRECISION",
":",
"opt",
".",
"precision",
";",
"// opt.precision only used in get... | Returns flattened length of the curve with precision better than `opt.precision`; or using `opt.subdivisions` provided. | [
"Returns",
"flattened",
"length",
"of",
"the",
"curve",
"with",
"precision",
"better",
"than",
"opt",
".",
"precision",
";",
"or",
"using",
"opt",
".",
"subdivisions",
"provided",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L1165-L1181 | train | |
clientIO/joint | dist/joint.nowrap.js | function(ratio, opt) {
if (!this.isDifferentiable()) return null;
if (ratio < 0) ratio = 0;
else if (ratio > 1) ratio = 1;
var t = this.tAt(ratio, opt);
return this.tangentAtT(t);
} | javascript | function(ratio, opt) {
if (!this.isDifferentiable()) return null;
if (ratio < 0) ratio = 0;
else if (ratio > 1) ratio = 1;
var t = this.tAt(ratio, opt);
return this.tangentAtT(t);
} | [
"function",
"(",
"ratio",
",",
"opt",
")",
"{",
"if",
"(",
"!",
"this",
".",
"isDifferentiable",
"(",
")",
")",
"return",
"null",
";",
"if",
"(",
"ratio",
"<",
"0",
")",
"ratio",
"=",
"0",
";",
"else",
"if",
"(",
"ratio",
">",
"1",
")",
"ratio"... | Returns a tangent line at requested `ratio` with precision better than requested `opt.precision`; or using `opt.subdivisions` provided. | [
"Returns",
"a",
"tangent",
"line",
"at",
"requested",
"ratio",
"with",
"precision",
"better",
"than",
"requested",
"opt",
".",
"precision",
";",
"or",
"using",
"opt",
".",
"subdivisions",
"provided",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L1245-L1255 | train | |
clientIO/joint | dist/joint.nowrap.js | function(length, opt) {
if (!this.isDifferentiable()) return null;
var t = this.tAtLength(length, opt);
return this.tangentAtT(t);
} | javascript | function(length, opt) {
if (!this.isDifferentiable()) return null;
var t = this.tAtLength(length, opt);
return this.tangentAtT(t);
} | [
"function",
"(",
"length",
",",
"opt",
")",
"{",
"if",
"(",
"!",
"this",
".",
"isDifferentiable",
"(",
")",
")",
"return",
"null",
";",
"var",
"t",
"=",
"this",
".",
"tAtLength",
"(",
"length",
",",
"opt",
")",
";",
"return",
"this",
".",
"tangentA... | Returns a tangent line at requested `length` with precision better than requested `opt.precision`; or using `opt.subdivisions` provided. | [
"Returns",
"a",
"tangent",
"line",
"at",
"requested",
"length",
"with",
"precision",
"better",
"than",
"requested",
"opt",
".",
"precision",
";",
"or",
"using",
"opt",
".",
"subdivisions",
"provided",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L1258-L1265 | train | |
clientIO/joint | dist/joint.nowrap.js | function(t) {
if (!this.isDifferentiable()) return null;
if (t < 0) t = 0;
else if (t > 1) t = 1;
var skeletonPoints = this.getSkeletonPoints(t);
var p1 = skeletonPoints.startControlPoint2;
var p2 = skeletonPoints.dividerControlPoint1;
... | javascript | function(t) {
if (!this.isDifferentiable()) return null;
if (t < 0) t = 0;
else if (t > 1) t = 1;
var skeletonPoints = this.getSkeletonPoints(t);
var p1 = skeletonPoints.startControlPoint2;
var p2 = skeletonPoints.dividerControlPoint1;
... | [
"function",
"(",
"t",
")",
"{",
"if",
"(",
"!",
"this",
".",
"isDifferentiable",
"(",
")",
")",
"return",
"null",
";",
"if",
"(",
"t",
"<",
"0",
")",
"t",
"=",
"0",
";",
"else",
"if",
"(",
"t",
">",
"1",
")",
"t",
"=",
"1",
";",
"var",
"s... | Returns a tangent line at requested `t`. | [
"Returns",
"a",
"tangent",
"line",
"at",
"requested",
"t",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L1268-L1286 | train | |
clientIO/joint | dist/joint.nowrap.js | function(ratio, opt) {
if (ratio <= 0) return 0;
if (ratio >= 1) return 1;
opt = opt || {};
var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;
var subdivisions = (opt.subdivisions === undefined) ? this.getSubdivisions({ precision... | javascript | function(ratio, opt) {
if (ratio <= 0) return 0;
if (ratio >= 1) return 1;
opt = opt || {};
var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;
var subdivisions = (opt.subdivisions === undefined) ? this.getSubdivisions({ precision... | [
"function",
"(",
"ratio",
",",
"opt",
")",
"{",
"if",
"(",
"ratio",
"<=",
"0",
")",
"return",
"0",
";",
"if",
"(",
"ratio",
">=",
"1",
")",
"return",
"1",
";",
"opt",
"=",
"opt",
"||",
"{",
"}",
";",
"var",
"precision",
"=",
"(",
"opt",
".",
... | Returns `t` at requested `ratio` with precision better than requested `opt.precision`; optionally using `opt.subdivisions` provided. | [
"Returns",
"t",
"at",
"requested",
"ratio",
"with",
"precision",
"better",
"than",
"requested",
"opt",
".",
"precision",
";",
"optionally",
"using",
"opt",
".",
"subdivisions",
"provided",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L1289-L1303 | train | |
clientIO/joint | dist/joint.nowrap.js | function(dx, dy) {
if (dx === undefined) {
dx = 0;
}
if (dy === undefined) {
dy = dx;
}
this.a += 2 * dx;
this.b += 2 * dy;
return this;
} | javascript | function(dx, dy) {
if (dx === undefined) {
dx = 0;
}
if (dy === undefined) {
dy = dx;
}
this.a += 2 * dx;
this.b += 2 * dy;
return this;
} | [
"function",
"(",
"dx",
",",
"dy",
")",
"{",
"if",
"(",
"dx",
"===",
"undefined",
")",
"{",
"dx",
"=",
"0",
";",
"}",
"if",
"(",
"dy",
"===",
"undefined",
")",
"{",
"dy",
"=",
"dx",
";",
"}",
"this",
".",
"a",
"+=",
"2",
"*",
"dx",
";",
"t... | inflate by dx and dy @param dx {delta_x} representing additional size to x @param dy {delta_y} representing additional size to y - dy param is not required -> in that case y is sized by dx | [
"inflate",
"by",
"dx",
"and",
"dy"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L1519-L1532 | train | |
clientIO/joint | dist/joint.nowrap.js | function(p) {
var refPointDelta = 30;
var x0 = p.x;
var y0 = p.y;
var a = this.a;
var b = this.b;
var center = this.bbox().center();
var m = center.x;
var n = center.y;
var q1 = x0 > center.x + a / 2;
... | javascript | function(p) {
var refPointDelta = 30;
var x0 = p.x;
var y0 = p.y;
var a = this.a;
var b = this.b;
var center = this.bbox().center();
var m = center.x;
var n = center.y;
var q1 = x0 > center.x + a / 2;
... | [
"function",
"(",
"p",
")",
"{",
"var",
"refPointDelta",
"=",
"30",
";",
"var",
"x0",
"=",
"p",
".",
"x",
";",
"var",
"y0",
"=",
"p",
".",
"y",
";",
"var",
"a",
"=",
"this",
".",
"a",
";",
"var",
"b",
"=",
"this",
".",
"b",
";",
"var",
"ce... | Compute angle between tangent and x axis
@param {g.Point} p Point of tangency, it has to be on ellipse boundaries.
@returns {number} angle between tangent and x axis | [
"Compute",
"angle",
"between",
"tangent",
"and",
"x",
"axis"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L1632-L1658 | train | |
clientIO/joint | dist/joint.nowrap.js | function(arg) {
var segments = this.segments;
var numSegments = segments.length;
// works even if path has no segments
var currentSegment;
var previousSegment = ((numSegments !== 0) ? segments[numSegments - 1] : null); // if we are appending to an empty pat... | javascript | function(arg) {
var segments = this.segments;
var numSegments = segments.length;
// works even if path has no segments
var currentSegment;
var previousSegment = ((numSegments !== 0) ? segments[numSegments - 1] : null); // if we are appending to an empty pat... | [
"function",
"(",
"arg",
")",
"{",
"var",
"segments",
"=",
"this",
".",
"segments",
";",
"var",
"numSegments",
"=",
"segments",
".",
"length",
";",
"// works even if path has no segments",
"var",
"currentSegment",
";",
"var",
"previousSegment",
"=",
"(",
"(",
"... | Accepts one segment or an array of segments as argument. Throws an error if argument is not a segment or an array of segments. | [
"Accepts",
"one",
"segment",
"or",
"an",
"array",
"of",
"segments",
"as",
"argument",
".",
"Throws",
"an",
"error",
"if",
"argument",
"is",
"not",
"a",
"segment",
"or",
"an",
"array",
"of",
"segments",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L2102-L2131 | train | |
clientIO/joint | dist/joint.nowrap.js | function() {
var segments = this.segments;
var numSegments = segments.length;
if (numSegments === 0) return null; // if segments is an empty array
var bbox;
for (var i = 0; i < numSegments; i++) {
var segment = segments[i];
i... | javascript | function() {
var segments = this.segments;
var numSegments = segments.length;
if (numSegments === 0) return null; // if segments is an empty array
var bbox;
for (var i = 0; i < numSegments; i++) {
var segment = segments[i];
i... | [
"function",
"(",
")",
"{",
"var",
"segments",
"=",
"this",
".",
"segments",
";",
"var",
"numSegments",
"=",
"segments",
".",
"length",
";",
"if",
"(",
"numSegments",
"===",
"0",
")",
"return",
"null",
";",
"// if segments is an empty array",
"var",
"bbox",
... | Returns the bbox of the path. If path has no segments, returns null. If path has only invisible segments, returns bbox of the end point of last segment. | [
"Returns",
"the",
"bbox",
"of",
"the",
"path",
".",
"If",
"path",
"has",
"no",
"segments",
"returns",
"null",
".",
"If",
"path",
"has",
"only",
"invisible",
"segments",
"returns",
"bbox",
"of",
"the",
"end",
"point",
"of",
"last",
"segment",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L2136-L2157 | train | |
clientIO/joint | dist/joint.nowrap.js | function() {
var segments = this.segments;
var numSegments = segments.length;
// works even if path has no segments
var path = new Path();
for (var i = 0; i < numSegments; i++) {
var segment = segments[i].clone();
path.append... | javascript | function() {
var segments = this.segments;
var numSegments = segments.length;
// works even if path has no segments
var path = new Path();
for (var i = 0; i < numSegments; i++) {
var segment = segments[i].clone();
path.append... | [
"function",
"(",
")",
"{",
"var",
"segments",
"=",
"this",
".",
"segments",
";",
"var",
"numSegments",
"=",
"segments",
".",
"length",
";",
"// works even if path has no segments",
"var",
"path",
"=",
"new",
"Path",
"(",
")",
";",
"for",
"(",
"var",
"i",
... | Returns a new path that is a clone of this path. | [
"Returns",
"a",
"new",
"path",
"that",
"is",
"a",
"clone",
"of",
"this",
"path",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L2160-L2174 | train | |
clientIO/joint | dist/joint.nowrap.js | function(p) {
if (!p) return false;
var segments = this.segments;
var otherSegments = p.segments;
var numSegments = segments.length;
if (otherSegments.length !== numSegments) return false; // if the two paths have different number of segments, they cannot b... | javascript | function(p) {
if (!p) return false;
var segments = this.segments;
var otherSegments = p.segments;
var numSegments = segments.length;
if (otherSegments.length !== numSegments) return false; // if the two paths have different number of segments, they cannot b... | [
"function",
"(",
"p",
")",
"{",
"if",
"(",
"!",
"p",
")",
"return",
"false",
";",
"var",
"segments",
"=",
"this",
".",
"segments",
";",
"var",
"otherSegments",
"=",
"p",
".",
"segments",
";",
"var",
"numSegments",
"=",
"segments",
".",
"length",
";",... | Checks whether two paths are exactly the same. If `p` is undefined or null, returns false. | [
"Checks",
"whether",
"two",
"paths",
"are",
"exactly",
"the",
"same",
".",
"If",
"p",
"is",
"undefined",
"or",
"null",
"returns",
"false",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L2288-L2309 | train | |
clientIO/joint | dist/joint.nowrap.js | function(index) {
var segments = this.segments;
var numSegments = segments.length;
if (numSegments === 0) throw new Error('Path has no segments.');
if (index < 0) index = numSegments + index; // convert negative indices to positive
if (index >= numSegments |... | javascript | function(index) {
var segments = this.segments;
var numSegments = segments.length;
if (numSegments === 0) throw new Error('Path has no segments.');
if (index < 0) index = numSegments + index; // convert negative indices to positive
if (index >= numSegments |... | [
"function",
"(",
"index",
")",
"{",
"var",
"segments",
"=",
"this",
".",
"segments",
";",
"var",
"numSegments",
"=",
"segments",
".",
"length",
";",
"if",
"(",
"numSegments",
"===",
"0",
")",
"throw",
"new",
"Error",
"(",
"'Path has no segments.'",
")",
... | Accepts negative indices. Throws an error if path has no segments. Throws an error if index is out of range. | [
"Accepts",
"negative",
"indices",
".",
"Throws",
"an",
"error",
"if",
"path",
"has",
"no",
"segments",
".",
"Throws",
"an",
"error",
"if",
"index",
"is",
"out",
"of",
"range",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L2314-L2324 | train | |
clientIO/joint | dist/joint.nowrap.js | function(opt) {
var segments = this.segments;
var numSegments = segments.length;
// works even if path has no segments
opt = opt || {};
var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;
// not using opt.segmentSubdiv... | javascript | function(opt) {
var segments = this.segments;
var numSegments = segments.length;
// works even if path has no segments
opt = opt || {};
var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;
// not using opt.segmentSubdiv... | [
"function",
"(",
"opt",
")",
"{",
"var",
"segments",
"=",
"this",
".",
"segments",
";",
"var",
"numSegments",
"=",
"segments",
".",
"length",
";",
"// works even if path has no segments",
"opt",
"=",
"opt",
"||",
"{",
"}",
";",
"var",
"precision",
"=",
"("... | Returns an array of segment subdivisions, with precision better than requested `opt.precision`. | [
"Returns",
"an",
"array",
"of",
"segment",
"subdivisions",
"with",
"precision",
"better",
"than",
"requested",
"opt",
".",
"precision",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L2327-L2347 | train | |
clientIO/joint | dist/joint.nowrap.js | function(opt) {
var segments = this.segments;
var numSegments = segments.length;
if (numSegments === 0) return 0; // if segments is an empty array
opt = opt || {};
var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision; // opt.precisi... | javascript | function(opt) {
var segments = this.segments;
var numSegments = segments.length;
if (numSegments === 0) return 0; // if segments is an empty array
opt = opt || {};
var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision; // opt.precisi... | [
"function",
"(",
"opt",
")",
"{",
"var",
"segments",
"=",
"this",
".",
"segments",
";",
"var",
"numSegments",
"=",
"segments",
".",
"length",
";",
"if",
"(",
"numSegments",
"===",
"0",
")",
"return",
"0",
";",
"// if segments is an empty array",
"opt",
"="... | Returns length of the path, with precision better than requested `opt.precision`; or using `opt.segmentSubdivisions` provided. If path has no segments, returns 0. | [
"Returns",
"length",
"of",
"the",
"path",
"with",
"precision",
"better",
"than",
"requested",
"opt",
".",
"precision",
";",
"or",
"using",
"opt",
".",
"segmentSubdivisions",
"provided",
".",
"If",
"path",
"has",
"no",
"segments",
"returns",
"0",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L2451-L2471 | train | |
clientIO/joint | dist/joint.nowrap.js | function(ratio, opt) {
var segments = this.segments;
var numSegments = segments.length;
if (numSegments === 0) return null; // if segments is an empty array
if (ratio <= 0) return this.start.clone();
if (ratio >= 1) return this.end.clone();
opt ... | javascript | function(ratio, opt) {
var segments = this.segments;
var numSegments = segments.length;
if (numSegments === 0) return null; // if segments is an empty array
if (ratio <= 0) return this.start.clone();
if (ratio >= 1) return this.end.clone();
opt ... | [
"function",
"(",
"ratio",
",",
"opt",
")",
"{",
"var",
"segments",
"=",
"this",
".",
"segments",
";",
"var",
"numSegments",
"=",
"segments",
".",
"length",
";",
"if",
"(",
"numSegments",
"===",
"0",
")",
"return",
"null",
";",
"// if segments is an empty a... | Returns point at requested `ratio` between 0 and 1, with precision better than requested `opt.precision`; optionally using `opt.segmentSubdivisions` provided. | [
"Returns",
"point",
"at",
"requested",
"ratio",
"between",
"0",
"and",
"1",
"with",
"precision",
"better",
"than",
"requested",
"opt",
".",
"precision",
";",
"optionally",
"using",
"opt",
".",
"segmentSubdivisions",
"provided",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L2513-L2531 | train | |
clientIO/joint | dist/joint.nowrap.js | function(length, opt) {
var segments = this.segments;
var numSegments = segments.length;
if (numSegments === 0) return null; // if segments is an empty array
if (length === 0) return this.start.clone();
var fromStart = true;
if (length < 0) {
... | javascript | function(length, opt) {
var segments = this.segments;
var numSegments = segments.length;
if (numSegments === 0) return null; // if segments is an empty array
if (length === 0) return this.start.clone();
var fromStart = true;
if (length < 0) {
... | [
"function",
"(",
"length",
",",
"opt",
")",
"{",
"var",
"segments",
"=",
"this",
".",
"segments",
";",
"var",
"numSegments",
"=",
"segments",
".",
"length",
";",
"if",
"(",
"numSegments",
"===",
"0",
")",
"return",
"null",
";",
"// if segments is an empty ... | Returns point at requested `length`, with precision better than requested `opt.precision`; optionally using `opt.segmentSubdivisions` provided. Accepts negative length. | [
"Returns",
"point",
"at",
"requested",
"length",
"with",
"precision",
"better",
"than",
"requested",
"opt",
".",
"precision",
";",
"optionally",
"using",
"opt",
".",
"segmentSubdivisions",
"provided",
".",
"Accepts",
"negative",
"length",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L2535-L2579 | train | |
clientIO/joint | dist/joint.nowrap.js | function(segment, previousSegment, nextSegment) {
// insert after previous segment and before previous segment's next segment
segment.previousSegment = previousSegment;
segment.nextSegment = nextSegment;
if (previousSegment) previousSegment.nextSegment = segment;
... | javascript | function(segment, previousSegment, nextSegment) {
// insert after previous segment and before previous segment's next segment
segment.previousSegment = previousSegment;
segment.nextSegment = nextSegment;
if (previousSegment) previousSegment.nextSegment = segment;
... | [
"function",
"(",
"segment",
",",
"previousSegment",
",",
"nextSegment",
")",
"{",
"// insert after previous segment and before previous segment's next segment",
"segment",
".",
"previousSegment",
"=",
"previousSegment",
";",
"segment",
".",
"nextSegment",
"=",
"nextSegment",
... | Helper method for adding segments. | [
"Helper",
"method",
"for",
"adding",
"segments",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L2603-L2621 | train | |
clientIO/joint | dist/joint.nowrap.js | function(index) {
var segments = this.segments;
var numSegments = segments.length;
if (numSegments === 0) throw new Error('Path has no segments.');
if (index < 0) index = numSegments + index; // convert negative indices to positive
if (index >= numSegments |... | javascript | function(index) {
var segments = this.segments;
var numSegments = segments.length;
if (numSegments === 0) throw new Error('Path has no segments.');
if (index < 0) index = numSegments + index; // convert negative indices to positive
if (index >= numSegments |... | [
"function",
"(",
"index",
")",
"{",
"var",
"segments",
"=",
"this",
".",
"segments",
";",
"var",
"numSegments",
"=",
"segments",
".",
"length",
";",
"if",
"(",
"numSegments",
"===",
"0",
")",
"throw",
"new",
"Error",
"(",
"'Path has no segments.'",
")",
... | Remove the segment at `index`. Accepts negative indices, from `-1` to `-segments.length`. Throws an error if path has no segments. Throws an error if index is out of range. | [
"Remove",
"the",
"segment",
"at",
"index",
".",
"Accepts",
"negative",
"indices",
"from",
"-",
"1",
"to",
"-",
"segments",
".",
"length",
".",
"Throws",
"an",
"error",
"if",
"path",
"has",
"no",
"segments",
".",
"Throws",
"an",
"error",
"if",
"index",
... | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L2627-L2646 | train | |
clientIO/joint | dist/joint.nowrap.js | function(length, opt) {
var segments = this.segments;
var numSegments = segments.length;
if (numSegments === 0) return null; // if segments is an empty array
var fromStart = true;
if (length < 0) {
fromStart = false; // negative lengths mean ... | javascript | function(length, opt) {
var segments = this.segments;
var numSegments = segments.length;
if (numSegments === 0) return null; // if segments is an empty array
var fromStart = true;
if (length < 0) {
fromStart = false; // negative lengths mean ... | [
"function",
"(",
"length",
",",
"opt",
")",
"{",
"var",
"segments",
"=",
"this",
".",
"segments",
";",
"var",
"numSegments",
"=",
"segments",
".",
"length",
";",
"if",
"(",
"numSegments",
"===",
"0",
")",
"return",
"null",
";",
"// if segments is an empty ... | Returns tangent line at requested `length`, with precision better than requested `opt.precision`; optionally using `opt.segmentSubdivisions` provided. Accepts negative length. | [
"Returns",
"tangent",
"line",
"at",
"requested",
"length",
"with",
"precision",
"better",
"than",
"requested",
"opt",
".",
"precision",
";",
"optionally",
"using",
"opt",
".",
"segmentSubdivisions",
"provided",
".",
"Accepts",
"negative",
"length",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L2822-L2866 | train | |
clientIO/joint | dist/joint.nowrap.js | function(segment) {
var previousSegment = segment.previousSegment; // may be null
while (segment && !segment.isSubpathStart) {
// assign previous segment's subpath start segment to this segment
if (previousSegment) segment.subpathStartSegment = previousSegment.s... | javascript | function(segment) {
var previousSegment = segment.previousSegment; // may be null
while (segment && !segment.isSubpathStart) {
// assign previous segment's subpath start segment to this segment
if (previousSegment) segment.subpathStartSegment = previousSegment.s... | [
"function",
"(",
"segment",
")",
"{",
"var",
"previousSegment",
"=",
"segment",
".",
"previousSegment",
";",
"// may be null",
"while",
"(",
"segment",
"&&",
"!",
"segment",
".",
"isSubpathStart",
")",
"{",
"// assign previous segment's subpath start segment to this seg... | Helper method for updating subpath start of segments, starting with the one provided. | [
"Helper",
"method",
"for",
"updating",
"subpath",
"start",
"of",
"segments",
"starting",
"with",
"the",
"one",
"provided",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L2966-L2978 | train | |
clientIO/joint | dist/joint.nowrap.js | function(ref, distance) {
var theta = toRad((new Point(ref)).theta(this));
var offset = this.offset(cos(theta) * distance, -sin(theta) * distance);
return offset;
} | javascript | function(ref, distance) {
var theta = toRad((new Point(ref)).theta(this));
var offset = this.offset(cos(theta) * distance, -sin(theta) * distance);
return offset;
} | [
"function",
"(",
"ref",
",",
"distance",
")",
"{",
"var",
"theta",
"=",
"toRad",
"(",
"(",
"new",
"Point",
"(",
"ref",
")",
")",
".",
"theta",
"(",
"this",
")",
")",
";",
"var",
"offset",
"=",
"this",
".",
"offset",
"(",
"cos",
"(",
"theta",
")... | Move point on line starting from ref ending at me by distance distance. | [
"Move",
"point",
"on",
"line",
"starting",
"from",
"ref",
"ending",
"at",
"me",
"by",
"distance",
"distance",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L3204-L3209 | train | |
clientIO/joint | dist/joint.nowrap.js | function(sx, sy, origin) {
origin = (origin && new Point(origin)) || new Point(0, 0);
this.x = origin.x + sx * (this.x - origin.x);
this.y = origin.y + sy * (this.y - origin.y);
return this;
} | javascript | function(sx, sy, origin) {
origin = (origin && new Point(origin)) || new Point(0, 0);
this.x = origin.x + sx * (this.x - origin.x);
this.y = origin.y + sy * (this.y - origin.y);
return this;
} | [
"function",
"(",
"sx",
",",
"sy",
",",
"origin",
")",
"{",
"origin",
"=",
"(",
"origin",
"&&",
"new",
"Point",
"(",
"origin",
")",
")",
"||",
"new",
"Point",
"(",
"0",
",",
"0",
")",
";",
"this",
".",
"x",
"=",
"origin",
".",
"x",
"+",
"sx",
... | Scale point with origin. | [
"Scale",
"point",
"with",
"origin",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L3265-L3271 | train | |
clientIO/joint | dist/joint.nowrap.js | function(o) {
o = (o && new Point(o)) || new Point(0, 0);
var x = this.x;
var y = this.y;
this.x = sqrt((x - o.x) * (x - o.x) + (y - o.y) * (y - o.y)); // r
this.y = toRad(o.theta(new Point(x, y)));
return this;
} | javascript | function(o) {
o = (o && new Point(o)) || new Point(0, 0);
var x = this.x;
var y = this.y;
this.x = sqrt((x - o.x) * (x - o.x) + (y - o.y) * (y - o.y)); // r
this.y = toRad(o.theta(new Point(x, y)));
return this;
} | [
"function",
"(",
"o",
")",
"{",
"o",
"=",
"(",
"o",
"&&",
"new",
"Point",
"(",
"o",
")",
")",
"||",
"new",
"Point",
"(",
"0",
",",
"0",
")",
";",
"var",
"x",
"=",
"this",
".",
"x",
";",
"var",
"y",
"=",
"this",
".",
"y",
";",
"this",
".... | Converts rectangular to polar coordinates. An origin can be specified, otherwise it's 0@0. | [
"Converts",
"rectangular",
"to",
"polar",
"coordinates",
".",
"An",
"origin",
"can",
"be",
"specified",
"otherwise",
"it",
"s",
"0"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L3312-L3320 | train | |
clientIO/joint | dist/joint.nowrap.js | function(p) {
if (!p) return false;
var points = this.points;
var otherPoints = p.points;
var numPoints = points.length;
if (otherPoints.length !== numPoints) return false; // if the two polylines have different number of points, they cannot be equal
... | javascript | function(p) {
if (!p) return false;
var points = this.points;
var otherPoints = p.points;
var numPoints = points.length;
if (otherPoints.length !== numPoints) return false; // if the two polylines have different number of points, they cannot be equal
... | [
"function",
"(",
"p",
")",
"{",
"if",
"(",
"!",
"p",
")",
"return",
"false",
";",
"var",
"points",
"=",
"this",
".",
"points",
";",
"var",
"otherPoints",
"=",
"p",
".",
"points",
";",
"var",
"numPoints",
"=",
"points",
".",
"length",
";",
"if",
"... | Checks whether two polylines are exactly the same. If `p` is undefined or null, returns false. | [
"Checks",
"whether",
"two",
"polylines",
"are",
"exactly",
"the",
"same",
".",
"If",
"p",
"is",
"undefined",
"or",
"null",
"returns",
"false",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L3686-L3707 | train | |
clientIO/joint | dist/joint.nowrap.js | function() {
var points = this.points;
var numPoints = points.length;
if (numPoints === 0) return ''; // if points array is empty
var output = '';
for (var i = 0; i < numPoints; i++) {
var point = points[i];
output += point.x... | javascript | function() {
var points = this.points;
var numPoints = points.length;
if (numPoints === 0) return ''; // if points array is empty
var output = '';
for (var i = 0; i < numPoints; i++) {
var point = points[i];
output += point.x... | [
"function",
"(",
")",
"{",
"var",
"points",
"=",
"this",
".",
"points",
";",
"var",
"numPoints",
"=",
"points",
".",
"length",
";",
"if",
"(",
"numPoints",
"===",
"0",
")",
"return",
"''",
";",
"// if points array is empty",
"var",
"output",
"=",
"''",
... | Return svgString that can be used to recreate this line. | [
"Return",
"svgString",
"that",
"can",
"be",
"used",
"to",
"recreate",
"this",
"line",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L3901-L3915 | train | |
clientIO/joint | dist/joint.nowrap.js | function(angle) {
if (!angle) return this.clone();
var theta = toRad(angle);
var st = abs(sin(theta));
var ct = abs(cos(theta));
var w = this.width * ct + this.height * st;
var h = this.width * st + this.height * ct;
return new Rect(t... | javascript | function(angle) {
if (!angle) return this.clone();
var theta = toRad(angle);
var st = abs(sin(theta));
var ct = abs(cos(theta));
var w = this.width * ct + this.height * st;
var h = this.width * st + this.height * ct;
return new Rect(t... | [
"function",
"(",
"angle",
")",
"{",
"if",
"(",
"!",
"angle",
")",
"return",
"this",
".",
"clone",
"(",
")",
";",
"var",
"theta",
"=",
"toRad",
"(",
"angle",
")",
";",
"var",
"st",
"=",
"abs",
"(",
"sin",
"(",
"theta",
")",
")",
";",
"var",
"c... | Find my bounding box when I'm rotated with the center of rotation in the center of me. @return r {rectangle} representing a bounding box | [
"Find",
"my",
"bounding",
"box",
"when",
"I",
"m",
"rotated",
"with",
"the",
"center",
"of",
"rotation",
"in",
"the",
"center",
"of",
"me",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L3981-L3991 | train | |
clientIO/joint | dist/joint.nowrap.js | function(p, angle) {
p = new Point(p);
var center = new Point(this.x + this.width / 2, this.y + this.height / 2);
var result;
if (angle) p.rotate(center, angle);
// (clockwise, starting from the top side)
var sides = [
this.topLi... | javascript | function(p, angle) {
p = new Point(p);
var center = new Point(this.x + this.width / 2, this.y + this.height / 2);
var result;
if (angle) p.rotate(center, angle);
// (clockwise, starting from the top side)
var sides = [
this.topLi... | [
"function",
"(",
"p",
",",
"angle",
")",
"{",
"p",
"=",
"new",
"Point",
"(",
"p",
")",
";",
"var",
"center",
"=",
"new",
"Point",
"(",
"this",
".",
"x",
"+",
"this",
".",
"width",
"/",
"2",
",",
"this",
".",
"y",
"+",
"this",
".",
"height",
... | Find point on my boundary where line starting from my center ending in point p intersects me. @param {number} angle If angle is specified, intersection with rotated rectangle is computed. | [
"Find",
"point",
"on",
"my",
"boundary",
"where",
"line",
"starting",
"from",
"my",
"center",
"ending",
"in",
"point",
"p",
"intersects",
"me",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L4132-L4158 | train | |
clientIO/joint | dist/joint.nowrap.js | function(sx, sy, origin) {
origin = this.origin().scale(sx, sy, origin);
this.x = origin.x;
this.y = origin.y;
this.width *= sx;
this.height *= sy;
return this;
} | javascript | function(sx, sy, origin) {
origin = this.origin().scale(sx, sy, origin);
this.x = origin.x;
this.y = origin.y;
this.width *= sx;
this.height *= sy;
return this;
} | [
"function",
"(",
"sx",
",",
"sy",
",",
"origin",
")",
"{",
"origin",
"=",
"this",
".",
"origin",
"(",
")",
".",
"scale",
"(",
"sx",
",",
"sy",
",",
"origin",
")",
";",
"this",
".",
"x",
"=",
"origin",
".",
"x",
";",
"this",
".",
"y",
"=",
"... | Scale rectangle with origin. | [
"Scale",
"rectangle",
"with",
"origin",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L4316-L4324 | train | |
clientIO/joint | dist/joint.nowrap.js | function(domain, range, value) {
var domainSpan = domain[1] - domain[0];
var rangeSpan = range[1] - range[0];
return (((value - domain[0]) / domainSpan) * rangeSpan + range[0]) || 0;
} | javascript | function(domain, range, value) {
var domainSpan = domain[1] - domain[0];
var rangeSpan = range[1] - range[0];
return (((value - domain[0]) / domainSpan) * rangeSpan + range[0]) || 0;
} | [
"function",
"(",
"domain",
",",
"range",
",",
"value",
")",
"{",
"var",
"domainSpan",
"=",
"domain",
"[",
"1",
"]",
"-",
"domain",
"[",
"0",
"]",
";",
"var",
"rangeSpan",
"=",
"range",
"[",
"1",
"]",
"-",
"range",
"[",
"0",
"]",
";",
"return",
... | Return the `value` from the `domain` interval scaled to the `range` interval. | [
"Return",
"the",
"value",
"from",
"the",
"domain",
"interval",
"scaled",
"to",
"the",
"range",
"interval",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L4416-L4421 | train | |
clientIO/joint | dist/joint.nowrap.js | function() {
var args = [];
var n = arguments.length;
for (var i = 0; i < n; i++) {
args.push(arguments[i]);
}
if (!(this instanceof Closepath)) { // switching context of `this` to Closepath when called without `new`
return applyToNew(Closepath, args);
... | javascript | function() {
var args = [];
var n = arguments.length;
for (var i = 0; i < n; i++) {
args.push(arguments[i]);
}
if (!(this instanceof Closepath)) { // switching context of `this` to Closepath when called without `new`
return applyToNew(Closepath, args);
... | [
"function",
"(",
")",
"{",
"var",
"args",
"=",
"[",
"]",
";",
"var",
"n",
"=",
"arguments",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"args",
".",
"push",
"(",
"arguments",
"[",
"i",... | does not inherit from any other geometry object | [
"does",
"not",
"inherit",
"from",
"any",
"other",
"geometry",
"object"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L5179-L5196 | train | |
clientIO/joint | dist/joint.nowrap.js | function(obj) {
this.guid.id = this.guid.id || 1;
obj.id = (obj.id === undefined ? 'j_' + this.guid.id++ : obj.id);
return obj.id;
} | javascript | function(obj) {
this.guid.id = this.guid.id || 1;
obj.id = (obj.id === undefined ? 'j_' + this.guid.id++ : obj.id);
return obj.id;
} | [
"function",
"(",
"obj",
")",
"{",
"this",
".",
"guid",
".",
"id",
"=",
"this",
".",
"guid",
".",
"id",
"||",
"1",
";",
"obj",
".",
"id",
"=",
"(",
"obj",
".",
"id",
"===",
"undefined",
"?",
"'j_'",
"+",
"this",
".",
"guid",
".",
"id",
"++",
... | Generate global unique id for obj and store it as a property of the object. | [
"Generate",
"global",
"unique",
"id",
"for",
"obj",
"and",
"store",
"it",
"as",
"a",
"property",
"of",
"the",
"object",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L7980-L7985 | train | |
clientIO/joint | dist/joint.nowrap.js | function(blob, fileName) {
if (window.navigator.msSaveBlob) { // requires IE 10+
// pulls up a save dialog
window.navigator.msSaveBlob(blob, fileName);
} else { // other browsers
// downloads directly in Chrome and Safari
// pres... | javascript | function(blob, fileName) {
if (window.navigator.msSaveBlob) { // requires IE 10+
// pulls up a save dialog
window.navigator.msSaveBlob(blob, fileName);
} else { // other browsers
// downloads directly in Chrome and Safari
// pres... | [
"function",
"(",
"blob",
",",
"fileName",
")",
"{",
"if",
"(",
"window",
".",
"navigator",
".",
"msSaveBlob",
")",
"{",
"// requires IE 10+",
"// pulls up a save dialog",
"window",
".",
"navigator",
".",
"msSaveBlob",
"(",
"blob",
",",
"fileName",
")",
";",
... | Download `blob` as file with `fileName`. Does not work in IE9. | [
"Download",
"blob",
"as",
"file",
"with",
"fileName",
".",
"Does",
"not",
"work",
"in",
"IE9",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L8438-L8463 | train | |
clientIO/joint | dist/joint.nowrap.js | function(dataUri, fileName) {
var blob = joint.util.dataUriToBlob(dataUri);
joint.util.downloadBlob(blob, fileName);
} | javascript | function(dataUri, fileName) {
var blob = joint.util.dataUriToBlob(dataUri);
joint.util.downloadBlob(blob, fileName);
} | [
"function",
"(",
"dataUri",
",",
"fileName",
")",
"{",
"var",
"blob",
"=",
"joint",
".",
"util",
".",
"dataUriToBlob",
"(",
"dataUri",
")",
";",
"joint",
".",
"util",
".",
"downloadBlob",
"(",
"blob",
",",
"fileName",
")",
";",
"}"
] | Download `dataUri` as file with `fileName`. Does not work in IE9. | [
"Download",
"dataUri",
"as",
"file",
"with",
"fileName",
".",
"Does",
"not",
"work",
"in",
"IE9",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L8467-L8471 | train | |
clientIO/joint | dist/joint.nowrap.js | function(url, callback) {
if (!url || url.substr(0, 'data:'.length) === 'data:') {
// No need to convert to data uri if it is already in data uri.
// This not only convenient but desired. For example,
// IE throws a security error if data:image/svg+xml is us... | javascript | function(url, callback) {
if (!url || url.substr(0, 'data:'.length) === 'data:') {
// No need to convert to data uri if it is already in data uri.
// This not only convenient but desired. For example,
// IE throws a security error if data:image/svg+xml is us... | [
"function",
"(",
"url",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"url",
"||",
"url",
".",
"substr",
"(",
"0",
",",
"'data:'",
".",
"length",
")",
"===",
"'data:'",
")",
"{",
"// No need to convert to data uri if it is already in data uri.",
"// This not only c... | Read an image at `url` and return it as base64-encoded data uri. The mime type of the image is inferred from the `url` file extension. If data uri is provided as `url`, it is returned back unchanged. `callback` is a method with `err` as first argument and `dataUri` as second argument. Works with IE9. | [
"Read",
"an",
"image",
"at",
"url",
"and",
"return",
"it",
"as",
"base64",
"-",
"encoded",
"data",
"uri",
".",
"The",
"mime",
"type",
"of",
"the",
"image",
"is",
"inferred",
"from",
"the",
"url",
"file",
"extension",
".",
"If",
"data",
"uri",
"is",
"... | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L8507-L8591 | train | |
clientIO/joint | dist/joint.nowrap.js | function(xhr, callback) {
if (xhr.status === 200) {
var reader = new FileReader();
reader.onload = function(evt) {
var dataUri = evt.target.result;
callback(null, dataUri);
};
... | javascript | function(xhr, callback) {
if (xhr.status === 200) {
var reader = new FileReader();
reader.onload = function(evt) {
var dataUri = evt.target.result;
callback(null, dataUri);
};
... | [
"function",
"(",
"xhr",
",",
"callback",
")",
"{",
"if",
"(",
"xhr",
".",
"status",
"===",
"200",
")",
"{",
"var",
"reader",
"=",
"new",
"FileReader",
"(",
")",
";",
"reader",
".",
"onload",
"=",
"function",
"(",
"evt",
")",
"{",
"var",
"dataUri",
... | chrome, IE10+ | [
"chrome",
"IE10",
"+"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L8525-L8544 | train | |
clientIO/joint | dist/joint.nowrap.js | function(el) {
this.$el = el instanceof Backbone.$ ? el : Backbone.$(el);
this.el = this.$el[0];
if (this.svgElement) this.vel = V(this.el);
} | javascript | function(el) {
this.$el = el instanceof Backbone.$ ? el : Backbone.$(el);
this.el = this.$el[0];
if (this.svgElement) this.vel = V(this.el);
} | [
"function",
"(",
"el",
")",
"{",
"this",
".",
"$el",
"=",
"el",
"instanceof",
"Backbone",
".",
"$",
"?",
"el",
":",
"Backbone",
".",
"$",
"(",
"el",
")",
";",
"this",
".",
"el",
"=",
"this",
".",
"$el",
"[",
"0",
"]",
";",
"if",
"(",
"this",
... | Utilize an alternative DOM manipulation API by adding an element reference wrapped in Vectorizer. | [
"Utilize",
"an",
"alternative",
"DOM",
"manipulation",
"API",
"by",
"adding",
"an",
"element",
"reference",
"wrapped",
"in",
"Vectorizer",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L9649-L9653 | train | |
clientIO/joint | dist/joint.nowrap.js | function(cells, opt) {
var preparedCells = joint.util.toArray(cells).map(function(cell) {
return this._prepareCell(cell, opt);
}, this);
this.get('cells').reset(preparedCells, opt);
return this;
} | javascript | function(cells, opt) {
var preparedCells = joint.util.toArray(cells).map(function(cell) {
return this._prepareCell(cell, opt);
}, this);
this.get('cells').reset(preparedCells, opt);
return this;
} | [
"function",
"(",
"cells",
",",
"opt",
")",
"{",
"var",
"preparedCells",
"=",
"joint",
".",
"util",
".",
"toArray",
"(",
"cells",
")",
".",
"map",
"(",
"function",
"(",
"cell",
")",
"{",
"return",
"this",
".",
"_prepareCell",
"(",
"cell",
",",
"opt",
... | When adding a lot of cells, it is much more efficient to reset the entire cells collection in one go. Useful for bulk operations and optimizations. | [
"When",
"adding",
"a",
"lot",
"of",
"cells",
"it",
"is",
"much",
"more",
"efficient",
"to",
"reset",
"the",
"entire",
"cells",
"collection",
"in",
"one",
"go",
".",
"Useful",
"for",
"bulk",
"operations",
"and",
"optimizations",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L10185-L10193 | train | |
clientIO/joint | dist/joint.nowrap.js | function(elementA, elementB) {
var isSuccessor = false;
this.search(elementA, function(element) {
if (element === elementB && element !== elementA) {
isSuccessor = true;
return false;
}
}, { outbound: true });
return isSuccessor;
... | javascript | function(elementA, elementB) {
var isSuccessor = false;
this.search(elementA, function(element) {
if (element === elementB && element !== elementA) {
isSuccessor = true;
return false;
}
}, { outbound: true });
return isSuccessor;
... | [
"function",
"(",
"elementA",
",",
"elementB",
")",
"{",
"var",
"isSuccessor",
"=",
"false",
";",
"this",
".",
"search",
"(",
"elementA",
",",
"function",
"(",
"element",
")",
"{",
"if",
"(",
"element",
"===",
"elementB",
"&&",
"element",
"!==",
"elementA... | Return `true` is `elementB` is a successor of `elementA`. Return `false` otherwise. | [
"Return",
"true",
"is",
"elementB",
"is",
"a",
"successor",
"of",
"elementA",
".",
"Return",
"false",
"otherwise",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L10723-L10733 | train | |
clientIO/joint | dist/joint.nowrap.js | function(elementA, elementB) {
var isPredecessor = false;
this.search(elementA, function(element) {
if (element === elementB && element !== elementA) {
isPredecessor = true;
return false;
}
}, { inbound: true });
return isPredecess... | javascript | function(elementA, elementB) {
var isPredecessor = false;
this.search(elementA, function(element) {
if (element === elementB && element !== elementA) {
isPredecessor = true;
return false;
}
}, { inbound: true });
return isPredecess... | [
"function",
"(",
"elementA",
",",
"elementB",
")",
"{",
"var",
"isPredecessor",
"=",
"false",
";",
"this",
".",
"search",
"(",
"elementA",
",",
"function",
"(",
"element",
")",
"{",
"if",
"(",
"element",
"===",
"elementB",
"&&",
"element",
"!==",
"elemen... | Return `true` is `elementB` is a predecessor of `elementA`. Return `false` otherwise. | [
"Return",
"true",
"is",
"elementB",
"is",
"a",
"predecessor",
"of",
"elementA",
".",
"Return",
"false",
"otherwise",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L10736-L10746 | train | |
clientIO/joint | dist/joint.nowrap.js | function(model, opt) {
this.getConnectedLinks(model).forEach(function(link) {
link.set((link.source().id === model.id ? 'source' : 'target'), { x: 0, y: 0 }, opt);
});
} | javascript | function(model, opt) {
this.getConnectedLinks(model).forEach(function(link) {
link.set((link.source().id === model.id ? 'source' : 'target'), { x: 0, y: 0 }, opt);
});
} | [
"function",
"(",
"model",
",",
"opt",
")",
"{",
"this",
".",
"getConnectedLinks",
"(",
"model",
")",
".",
"forEach",
"(",
"function",
"(",
"link",
")",
"{",
"link",
".",
"set",
"(",
"(",
"link",
".",
"source",
"(",
")",
".",
"id",
"===",
"model",
... | Disconnect links connected to the cell `model`. | [
"Disconnect",
"links",
"connected",
"to",
"the",
"cell",
"model",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L10787-L10793 | train | |
clientIO/joint | dist/joint.nowrap.js | function(rect, opt) {
rect = g.rect(rect);
opt = joint.util.defaults(opt || {}, { strict: false });
var method = opt.strict ? 'containsRect' : 'intersect';
return this.getElements().filter(function(el) {
return rect[method](el.getBBox());
});
} | javascript | function(rect, opt) {
rect = g.rect(rect);
opt = joint.util.defaults(opt || {}, { strict: false });
var method = opt.strict ? 'containsRect' : 'intersect';
return this.getElements().filter(function(el) {
return rect[method](el.getBBox());
});
} | [
"function",
"(",
"rect",
",",
"opt",
")",
"{",
"rect",
"=",
"g",
".",
"rect",
"(",
"rect",
")",
";",
"opt",
"=",
"joint",
".",
"util",
".",
"defaults",
"(",
"opt",
"||",
"{",
"}",
",",
"{",
"strict",
":",
"false",
"}",
")",
";",
"var",
"metho... | Find all elements in given area | [
"Find",
"all",
"elements",
"in",
"given",
"area"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L10810-L10820 | train | |
clientIO/joint | dist/joint.nowrap.js | function(element, opt) {
opt = joint.util.defaults(opt || {}, { searchBy: 'bbox' });
var bbox = element.getBBox();
var elements = (opt.searchBy === 'bbox')
? this.findModelsInArea(bbox)
: this.findModelsFromPoint(bbox[opt.searchBy]());
// don't account element ... | javascript | function(element, opt) {
opt = joint.util.defaults(opt || {}, { searchBy: 'bbox' });
var bbox = element.getBBox();
var elements = (opt.searchBy === 'bbox')
? this.findModelsInArea(bbox)
: this.findModelsFromPoint(bbox[opt.searchBy]());
// don't account element ... | [
"function",
"(",
"element",
",",
"opt",
")",
"{",
"opt",
"=",
"joint",
".",
"util",
".",
"defaults",
"(",
"opt",
"||",
"{",
"}",
",",
"{",
"searchBy",
":",
"'bbox'",
"}",
")",
";",
"var",
"bbox",
"=",
"element",
".",
"getBBox",
"(",
")",
";",
"... | Find all elements under the given element. | [
"Find",
"all",
"elements",
"under",
"the",
"given",
"element",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L10823-L10836 | train | |
clientIO/joint | dist/joint.nowrap.js | function(cells, opt) {
return joint.util.toArray(cells).reduce(function(memo, cell) {
if (cell.isLink()) return memo;
var rect = cell.getBBox(opt);
var angle = cell.angle();
if (angle) rect = rect.bbox(angle);
if (memo) {
return memo.u... | javascript | function(cells, opt) {
return joint.util.toArray(cells).reduce(function(memo, cell) {
if (cell.isLink()) return memo;
var rect = cell.getBBox(opt);
var angle = cell.angle();
if (angle) rect = rect.bbox(angle);
if (memo) {
return memo.u... | [
"function",
"(",
"cells",
",",
"opt",
")",
"{",
"return",
"joint",
".",
"util",
".",
"toArray",
"(",
"cells",
")",
".",
"reduce",
"(",
"function",
"(",
"memo",
",",
"cell",
")",
"{",
"if",
"(",
"cell",
".",
"isLink",
"(",
")",
")",
"return",
"mem... | Return the bounding box of all cells in array provided. Links are being ignored. | [
"Return",
"the",
"bounding",
"box",
"of",
"all",
"cells",
"in",
"array",
"provided",
".",
"Links",
"are",
"being",
"ignored",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L10847-L10860 | train | |
clientIO/joint | dist/joint.nowrap.js | dWrapper | function dWrapper(opt) {
function pathConstructor(value) {
return new g.Path(V.normalizePathData(value));
}
var shape = shapeWrapper(pathConstructor, opt);
return function(value, refBBox, node) {
var path = shape(value, refBBox, node);
return {
... | javascript | function dWrapper(opt) {
function pathConstructor(value) {
return new g.Path(V.normalizePathData(value));
}
var shape = shapeWrapper(pathConstructor, opt);
return function(value, refBBox, node) {
var path = shape(value, refBBox, node);
return {
... | [
"function",
"dWrapper",
"(",
"opt",
")",
"{",
"function",
"pathConstructor",
"(",
"value",
")",
"{",
"return",
"new",
"g",
".",
"Path",
"(",
"V",
".",
"normalizePathData",
"(",
"value",
")",
")",
";",
"}",
"var",
"shape",
"=",
"shapeWrapper",
"(",
"pat... | `d` attribute for SVGPaths | [
"d",
"attribute",
"for",
"SVGPaths"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L11078-L11089 | train |
clientIO/joint | dist/joint.nowrap.js | pointsWrapper | function pointsWrapper(opt) {
var shape = shapeWrapper(g.Polyline, opt);
return function(value, refBBox, node) {
var polyline = shape(value, refBBox, node);
return {
points: polyline.serialize()
};
};
} | javascript | function pointsWrapper(opt) {
var shape = shapeWrapper(g.Polyline, opt);
return function(value, refBBox, node) {
var polyline = shape(value, refBBox, node);
return {
points: polyline.serialize()
};
};
} | [
"function",
"pointsWrapper",
"(",
"opt",
")",
"{",
"var",
"shape",
"=",
"shapeWrapper",
"(",
"g",
".",
"Polyline",
",",
"opt",
")",
";",
"return",
"function",
"(",
"value",
",",
"refBBox",
",",
"node",
")",
"{",
"var",
"polyline",
"=",
"shape",
"(",
... | `points` attribute for SVGPolylines and SVGPolygons | [
"points",
"attribute",
"for",
"SVGPolylines",
"and",
"SVGPolygons"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L11092-L11100 | train |
clientIO/joint | dist/joint.nowrap.js | function() {
var ancestors = [];
if (!this.graph) {
return ancestors;
}
var parentCell = this.getParentCell();
while (parentCell) {
ancestors.push(parentCell);
parentCell = parentCell.getParentCell();
}
return ancestors;
... | javascript | function() {
var ancestors = [];
if (!this.graph) {
return ancestors;
}
var parentCell = this.getParentCell();
while (parentCell) {
ancestors.push(parentCell);
parentCell = parentCell.getParentCell();
}
return ancestors;
... | [
"function",
"(",
")",
"{",
"var",
"ancestors",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"this",
".",
"graph",
")",
"{",
"return",
"ancestors",
";",
"}",
"var",
"parentCell",
"=",
"this",
".",
"getParentCell",
"(",
")",
";",
"while",
"(",
"parentCell",
"... | Return an array of ancestor cells. The array is ordered from the parent of the cell to the most distant ancestor. | [
"Return",
"an",
"array",
"of",
"ancestor",
"cells",
".",
"The",
"array",
"is",
"ordered",
"from",
"the",
"parent",
"of",
"the",
"cell",
"to",
"the",
"most",
"distant",
"ancestor",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L12071-L12086 | train | |
clientIO/joint | dist/joint.nowrap.js | function(path, opt) {
// Once a property is removed from the `attrs` attribute
// the cellView will recognize a `dirty` flag and rerender itself
// in order to remove the attribute from SVG element.
opt = opt || {};
opt.dirty = true;
var pathArray = Array.isArray(path) ... | javascript | function(path, opt) {
// Once a property is removed from the `attrs` attribute
// the cellView will recognize a `dirty` flag and rerender itself
// in order to remove the attribute from SVG element.
opt = opt || {};
opt.dirty = true;
var pathArray = Array.isArray(path) ... | [
"function",
"(",
"path",
",",
"opt",
")",
"{",
"// Once a property is removed from the `attrs` attribute",
"// the cellView will recognize a `dirty` flag and rerender itself",
"// in order to remove the attribute from SVG element.",
"opt",
"=",
"opt",
"||",
"{",
"}",
";",
"opt",
... | A convient way to unset nested properties | [
"A",
"convient",
"way",
"to",
"unset",
"nested",
"properties"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L12280-L12303 | train | |
clientIO/joint | dist/joint.nowrap.js | function(attrs, value, opt) {
var args = Array.from(arguments);
if (args.length === 0) {
return this.get('attrs');
}
if (Array.isArray(attrs)) {
args[0] = ['attrs'].concat(attrs);
} else if (joint.util.isString(attrs)) {
// Get/set an attribu... | javascript | function(attrs, value, opt) {
var args = Array.from(arguments);
if (args.length === 0) {
return this.get('attrs');
}
if (Array.isArray(attrs)) {
args[0] = ['attrs'].concat(attrs);
} else if (joint.util.isString(attrs)) {
// Get/set an attribu... | [
"function",
"(",
"attrs",
",",
"value",
",",
"opt",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"from",
"(",
"arguments",
")",
";",
"if",
"(",
"args",
".",
"length",
"===",
"0",
")",
"{",
"return",
"this",
".",
"get",
"(",
"'attrs'",
")",
";",
... | A convenient way to set nested attributes. | [
"A",
"convenient",
"way",
"to",
"set",
"nested",
"attributes",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L12306-L12326 | train | |
clientIO/joint | dist/joint.nowrap.js | function(path, opt) {
if (Array.isArray(path)) {
return this.removeProp(['attrs'].concat(path));
}
return this.removeProp('attrs/' + path, opt);
} | javascript | function(path, opt) {
if (Array.isArray(path)) {
return this.removeProp(['attrs'].concat(path));
}
return this.removeProp('attrs/' + path, opt);
} | [
"function",
"(",
"path",
",",
"opt",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"path",
")",
")",
"{",
"return",
"this",
".",
"removeProp",
"(",
"[",
"'attrs'",
"]",
".",
"concat",
"(",
"path",
")",
")",
";",
"}",
"return",
"this",
".",
... | A convenient way to unset nested attributes | [
"A",
"convenient",
"way",
"to",
"unset",
"nested",
"attributes"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L12329-L12337 | train | |
clientIO/joint | dist/joint.nowrap.js | function(el) {
var $el = this.$(el);
var $rootEl = this.$el;
if ($el.length === 0) {
$el = $rootEl;
}
do {
var magnet = $el.attr('magnet');
if ((magnet || $el.is($rootEl)) && magnet !== 'false') {
return $el[0];
... | javascript | function(el) {
var $el = this.$(el);
var $rootEl = this.$el;
if ($el.length === 0) {
$el = $rootEl;
}
do {
var magnet = $el.attr('magnet');
if ((magnet || $el.is($rootEl)) && magnet !== 'false') {
return $el[0];
... | [
"function",
"(",
"el",
")",
"{",
"var",
"$el",
"=",
"this",
".",
"$",
"(",
"el",
")",
";",
"var",
"$rootEl",
"=",
"this",
".",
"$el",
";",
"if",
"(",
"$el",
".",
"length",
"===",
"0",
")",
"{",
"$el",
"=",
"$rootEl",
";",
"}",
"do",
"{",
"v... | Find the closest element that has the `magnet` attribute set to `true`. If there was not such an element found, return the root element of the cell view. | [
"Find",
"the",
"closest",
"element",
"that",
"has",
"the",
"magnet",
"attribute",
"set",
"to",
"true",
".",
"If",
"there",
"was",
"not",
"such",
"an",
"element",
"found",
"return",
"the",
"root",
"element",
"of",
"the",
"cell",
"view",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L12672-L12697 | train | |
clientIO/joint | dist/joint.nowrap.js | function(el, prevSelector) {
var selector;
if (el === this.el) {
if (typeof prevSelector === 'string') selector = '> ' + prevSelector;
return selector;
}
if (el) {
var nthChild = V(el).index() + 1;
selector = el.tagName + ':nth-child(' ... | javascript | function(el, prevSelector) {
var selector;
if (el === this.el) {
if (typeof prevSelector === 'string') selector = '> ' + prevSelector;
return selector;
}
if (el) {
var nthChild = V(el).index() + 1;
selector = el.tagName + ':nth-child(' ... | [
"function",
"(",
"el",
",",
"prevSelector",
")",
"{",
"var",
"selector",
";",
"if",
"(",
"el",
"===",
"this",
".",
"el",
")",
"{",
"if",
"(",
"typeof",
"prevSelector",
"===",
"'string'",
")",
"selector",
"=",
"'> '",
"+",
"prevSelector",
";",
"return",... | Construct a unique selector for the `el` element within this view. `prevSelector` is being collected through the recursive call. No value for `prevSelector` is expected when using this method. | [
"Construct",
"a",
"unique",
"selector",
"for",
"the",
"el",
"element",
"within",
"this",
"view",
".",
"prevSelector",
"is",
"being",
"collected",
"through",
"the",
"recursive",
"call",
".",
"No",
"value",
"for",
"prevSelector",
"is",
"expected",
"when",
"using... | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L12702-L12724 | train | |
clientIO/joint | dist/joint.nowrap.js | function(angle, absolute, origin, opt) {
if (origin) {
var center = this.getBBox().center();
var size = this.get('size');
var position = this.get('position');
center.rotate(origin, this.get('angle') - angle);
var dx = center.x - size.width / 2 - posi... | javascript | function(angle, absolute, origin, opt) {
if (origin) {
var center = this.getBBox().center();
var size = this.get('size');
var position = this.get('position');
center.rotate(origin, this.get('angle') - angle);
var dx = center.x - size.width / 2 - posi... | [
"function",
"(",
"angle",
",",
"absolute",
",",
"origin",
",",
"opt",
")",
"{",
"if",
"(",
"origin",
")",
"{",
"var",
"center",
"=",
"this",
".",
"getBBox",
"(",
")",
".",
"center",
"(",
")",
";",
"var",
"size",
"=",
"this",
".",
"get",
"(",
"'... | Rotate element by `angle` degrees, optionally around `origin` point. If `origin` is not provided, it is considered to be the center of the element. If `absolute` is `true`, the `angle` is considered is abslute, i.e. it is not the difference from the previous angle. | [
"Rotate",
"element",
"by",
"angle",
"degrees",
"optionally",
"around",
"origin",
"point",
".",
"If",
"origin",
"is",
"not",
"provided",
"it",
"is",
"considered",
"to",
"be",
"the",
"center",
"of",
"the",
"element",
".",
"If",
"absolute",
"is",
"true",
"the... | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L13678-L13699 | train | |
clientIO/joint | dist/joint.nowrap.js | function() {
var element = this.model;
var markup = element.get('markup') || element.markup;
if (!markup) throw new Error('dia.ElementView: markup required');
if (Array.isArray(markup)) return this.renderJSONMarkup(markup);
if (typeof markup === 'string') return this.renderStrin... | javascript | function() {
var element = this.model;
var markup = element.get('markup') || element.markup;
if (!markup) throw new Error('dia.ElementView: markup required');
if (Array.isArray(markup)) return this.renderJSONMarkup(markup);
if (typeof markup === 'string') return this.renderStrin... | [
"function",
"(",
")",
"{",
"var",
"element",
"=",
"this",
".",
"model",
";",
"var",
"markup",
"=",
"element",
".",
"get",
"(",
"'markup'",
")",
"||",
"element",
".",
"markup",
";",
"if",
"(",
"!",
"markup",
")",
"throw",
"new",
"Error",
"(",
"'dia.... | `prototype.markup` is rendered by default. Set the `markup` attribute on the model if the default markup is not desirable. | [
"prototype",
".",
"markup",
"is",
"rendered",
"by",
"default",
".",
"Set",
"the",
"markup",
"attribute",
"on",
"the",
"model",
"if",
"the",
"default",
"markup",
"is",
"not",
"desirable",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L13808-L13816 | train | |
clientIO/joint | dist/joint.nowrap.js | function(evt, x, y) {
var data = this.eventData(evt);
if (data.embedding) this.finalizeEmbedding(data);
} | javascript | function(evt, x, y) {
var data = this.eventData(evt);
if (data.embedding) this.finalizeEmbedding(data);
} | [
"function",
"(",
"evt",
",",
"x",
",",
"y",
")",
"{",
"var",
"data",
"=",
"this",
".",
"eventData",
"(",
"evt",
")",
";",
"if",
"(",
"data",
".",
"embedding",
")",
"this",
".",
"finalizeEmbedding",
"(",
"data",
")",
";",
"}"
] | Drag End Handlers | [
"Drag",
"End",
"Handlers"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L14465-L14469 | train | |
clientIO/joint | dist/joint.nowrap.js | function(idx, label, opt) {
var labels = this.labels();
idx = (isFinite(idx) && idx !== null) ? (idx | 0) : 0;
if (idx < 0) idx = labels.length + idx;
// getter
if (arguments.length <= 1) return this.prop(['labels', idx]);
// setter
return this.prop(['labels', ... | javascript | function(idx, label, opt) {
var labels = this.labels();
idx = (isFinite(idx) && idx !== null) ? (idx | 0) : 0;
if (idx < 0) idx = labels.length + idx;
// getter
if (arguments.length <= 1) return this.prop(['labels', idx]);
// setter
return this.prop(['labels', ... | [
"function",
"(",
"idx",
",",
"label",
",",
"opt",
")",
"{",
"var",
"labels",
"=",
"this",
".",
"labels",
"(",
")",
";",
"idx",
"=",
"(",
"isFinite",
"(",
"idx",
")",
"&&",
"idx",
"!==",
"null",
")",
"?",
"(",
"idx",
"|",
"0",
")",
":",
"0",
... | Labels API A convenient way to set labels. Currently set values will be mixined with `value` if used as a setter. | [
"Labels",
"API",
"A",
"convenient",
"way",
"to",
"set",
"labels",
".",
"Currently",
"set",
"values",
"will",
"be",
"mixined",
"with",
"value",
"if",
"used",
"as",
"a",
"setter",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L14738-L14749 | train | |
clientIO/joint | dist/joint.nowrap.js | function() {
var connectionAncestor;
if (this.graph) {
var cells = [
this,
this.getSourceElement(), // null if source is a point
this.getTargetElement() // null if target is a point
].filter(function(item) {
retur... | javascript | function() {
var connectionAncestor;
if (this.graph) {
var cells = [
this,
this.getSourceElement(), // null if source is a point
this.getTargetElement() // null if target is a point
].filter(function(item) {
retur... | [
"function",
"(",
")",
"{",
"var",
"connectionAncestor",
";",
"if",
"(",
"this",
".",
"graph",
")",
"{",
"var",
"cells",
"=",
"[",
"this",
",",
"this",
".",
"getSourceElement",
"(",
")",
",",
"// null if source is a point",
"this",
".",
"getTargetElement",
... | Returns the common ancestor for the source element, target element and the link itself. | [
"Returns",
"the",
"common",
"ancestor",
"for",
"the",
"source",
"element",
"target",
"element",
"and",
"the",
"link",
"itself",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L14973-L14991 | train | |
clientIO/joint | dist/joint.nowrap.js | function(cell) {
var cellId = (joint.util.isString(cell) || joint.util.isNumber(cell)) ? cell : cell.id;
var ancestor = this.getRelationshipAncestor();
return !!ancestor && (ancestor.id === cellId || ancestor.isEmbeddedIn(cellId));
} | javascript | function(cell) {
var cellId = (joint.util.isString(cell) || joint.util.isNumber(cell)) ? cell : cell.id;
var ancestor = this.getRelationshipAncestor();
return !!ancestor && (ancestor.id === cellId || ancestor.isEmbeddedIn(cellId));
} | [
"function",
"(",
"cell",
")",
"{",
"var",
"cellId",
"=",
"(",
"joint",
".",
"util",
".",
"isString",
"(",
"cell",
")",
"||",
"joint",
".",
"util",
".",
"isNumber",
"(",
"cell",
")",
")",
"?",
"cell",
":",
"cell",
".",
"id",
";",
"var",
"ancestor"... | Is source, target and the link itself embedded in a given cell? | [
"Is",
"source",
"target",
"and",
"the",
"link",
"itself",
"embedded",
"in",
"a",
"given",
"cell?"
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L14994-L15000 | train | |
clientIO/joint | dist/joint.nowrap.js | function() {
var defaultLabel = this.get('defaultLabel') || this.defaultLabel || {};
var label = {};
label.markup = defaultLabel.markup || this.get('labelMarkup') || this.labelMarkup;
label.position = defaultLabel.position;
label.attrs = defaultLabel.attrs;
label.size =... | javascript | function() {
var defaultLabel = this.get('defaultLabel') || this.defaultLabel || {};
var label = {};
label.markup = defaultLabel.markup || this.get('labelMarkup') || this.labelMarkup;
label.position = defaultLabel.position;
label.attrs = defaultLabel.attrs;
label.size =... | [
"function",
"(",
")",
"{",
"var",
"defaultLabel",
"=",
"this",
".",
"get",
"(",
"'defaultLabel'",
")",
"||",
"this",
".",
"defaultLabel",
"||",
"{",
"}",
";",
"var",
"label",
"=",
"{",
"}",
";",
"label",
".",
"markup",
"=",
"defaultLabel",
".",
"mark... | Get resolved default label. | [
"Get",
"resolved",
"default",
"label",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L15003-L15014 | train | |
clientIO/joint | dist/joint.nowrap.js | function(endType) {
// create handler for specific end type (source|target).
var onModelChange = function(endModel, opt) {
this.onEndModelChange(endType, endModel, opt);
};
function watchEndModel(link, end) {
end = end || {};
var endModel = null;
... | javascript | function(endType) {
// create handler for specific end type (source|target).
var onModelChange = function(endModel, opt) {
this.onEndModelChange(endType, endModel, opt);
};
function watchEndModel(link, end) {
end = end || {};
var endModel = null;
... | [
"function",
"(",
"endType",
")",
"{",
"// create handler for specific end type (source|target).",
"var",
"onModelChange",
"=",
"function",
"(",
"endModel",
",",
"opt",
")",
"{",
"this",
".",
"onEndModelChange",
"(",
"endType",
",",
"endModel",
",",
"opt",
")",
";"... | Returns a function observing changes on an end of the link. If a change happens and new end is a new model, it stops listening on the previous one and starts listening to the new one. | [
"Returns",
"a",
"function",
"observing",
"changes",
"on",
"an",
"end",
"of",
"the",
"link",
".",
"If",
"a",
"change",
"happens",
"and",
"new",
"end",
"is",
"a",
"new",
"model",
"it",
"stops",
"listening",
"on",
"the",
"previous",
"one",
"and",
"starts",
... | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L15981-L16011 | train | |
clientIO/joint | dist/joint.nowrap.js | function(x, y, opt) {
// accept input in form `{ x, y }, opt` or `x, y, opt`
var isPointProvided = (typeof x !== 'number');
var localX = isPointProvided ? x.x : x;
var localY = isPointProvided ? x.y : y;
var localOpt = isPointProvided ? y : opt;
var vertex = { x: localX... | javascript | function(x, y, opt) {
// accept input in form `{ x, y }, opt` or `x, y, opt`
var isPointProvided = (typeof x !== 'number');
var localX = isPointProvided ? x.x : x;
var localY = isPointProvided ? x.y : y;
var localOpt = isPointProvided ? y : opt;
var vertex = { x: localX... | [
"function",
"(",
"x",
",",
"y",
",",
"opt",
")",
"{",
"// accept input in form `{ x, y }, opt` or `x, y, opt`",
"var",
"isPointProvided",
"=",
"(",
"typeof",
"x",
"!==",
"'number'",
")",
";",
"var",
"localX",
"=",
"isPointProvided",
"?",
"x",
".",
"x",
":",
... | Add a new vertex at calculated index to the `vertices` array. | [
"Add",
"a",
"new",
"vertex",
"at",
"calculated",
"index",
"to",
"the",
"vertices",
"array",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L16194-L16206 | train | |
clientIO/joint | dist/joint.nowrap.js | function(angle, cx, cy) {
// getter
if (angle === undefined) {
return V.matrixToRotate(this.matrix());
}
// setter
// If the origin is not set explicitely, rotate around the center. Note that
// we must use the plain bounding box (`this.el.getBBox()` instea... | javascript | function(angle, cx, cy) {
// getter
if (angle === undefined) {
return V.matrixToRotate(this.matrix());
}
// setter
// If the origin is not set explicitely, rotate around the center. Note that
// we must use the plain bounding box (`this.el.getBBox()` instea... | [
"function",
"(",
"angle",
",",
"cx",
",",
"cy",
")",
"{",
"// getter",
"if",
"(",
"angle",
"===",
"undefined",
")",
"{",
"return",
"V",
".",
"matrixToRotate",
"(",
"this",
".",
"matrix",
"(",
")",
")",
";",
"}",
"// setter",
"// If the origin is not set ... | Experimental - do not use in production. | [
"Experimental",
"-",
"do",
"not",
"use",
"in",
"production",
"."
] | 99ba02fe6c64e407bdfff6ba595d2068422c3e76 | https://github.com/clientIO/joint/blob/99ba02fe6c64e407bdfff6ba595d2068422c3e76/dist/joint.nowrap.js#L18161-L18183 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.