id
int32
0
58k
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
7,700
matrix-org/matrix-js-sdk
src/client.js
_encryptEventIfNeeded
function _encryptEventIfNeeded(client, event, room) { if (event.isEncrypted()) { // this event has already been encrypted; this happens if the // encryption step succeeded, but the send step failed on the first // attempt. return null; } if (!client.isRoomEncrypted(event.get...
javascript
function _encryptEventIfNeeded(client, event, room) { if (event.isEncrypted()) { // this event has already been encrypted; this happens if the // encryption step succeeded, but the send step failed on the first // attempt. return null; } if (!client.isRoomEncrypted(event.get...
[ "function", "_encryptEventIfNeeded", "(", "client", ",", "event", ",", "room", ")", "{", "if", "(", "event", ".", "isEncrypted", "(", ")", ")", "{", "// this event has already been encrypted; this happens if the", "// encryption step succeeded, but the send step failed on the...
Encrypt an event according to the configuration of the room, if necessary. @param {MatrixClient} client @param {module:models/event.MatrixEvent} event event to be sent @param {module:models/room?} room destination room. Null if the destination is not a room we have seen over the sync pipe. @return {module:client.P...
[ "Encrypt", "an", "event", "according", "to", "the", "configuration", "of", "the", "room", "if", "necessary", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/client.js#L1817-L1838
7,701
matrix-org/matrix-js-sdk
src/crypto/index.js
_maybeUploadOneTimeKeys
function _maybeUploadOneTimeKeys(crypto) { // frequency with which to check & upload one-time keys const uploadPeriod = 1000 * 60; // one minute // max number of keys to upload at once // Creating keys can be an expensive operation so we limit the // number we generate in one go to avoid blocking t...
javascript
function _maybeUploadOneTimeKeys(crypto) { // frequency with which to check & upload one-time keys const uploadPeriod = 1000 * 60; // one minute // max number of keys to upload at once // Creating keys can be an expensive operation so we limit the // number we generate in one go to avoid blocking t...
[ "function", "_maybeUploadOneTimeKeys", "(", "crypto", ")", "{", "// frequency with which to check & upload one-time keys", "const", "uploadPeriod", "=", "1000", "*", "60", ";", "// one minute", "// max number of keys to upload at once", "// Creating keys can be an expensive operation...
check if it's time to upload one-time keys, and do so if so.
[ "check", "if", "it", "s", "time", "to", "upload", "one", "-", "time", "keys", "and", "do", "so", "if", "so", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/crypto/index.js#L515-L611
7,702
matrix-org/matrix-js-sdk
src/crypto/index.js
_uploadOneTimeKeys
async function _uploadOneTimeKeys(crypto) { const oneTimeKeys = await crypto._olmDevice.getOneTimeKeys(); const oneTimeJson = {}; const promises = []; for (const keyId in oneTimeKeys.curve25519) { if (oneTimeKeys.curve25519.hasOwnProperty(keyId)) { const k = { key: ...
javascript
async function _uploadOneTimeKeys(crypto) { const oneTimeKeys = await crypto._olmDevice.getOneTimeKeys(); const oneTimeJson = {}; const promises = []; for (const keyId in oneTimeKeys.curve25519) { if (oneTimeKeys.curve25519.hasOwnProperty(keyId)) { const k = { key: ...
[ "async", "function", "_uploadOneTimeKeys", "(", "crypto", ")", "{", "const", "oneTimeKeys", "=", "await", "crypto", ".", "_olmDevice", ".", "getOneTimeKeys", "(", ")", ";", "const", "oneTimeJson", "=", "{", "}", ";", "const", "promises", "=", "[", "]", ";"...
returns a promise which resolves to the response
[ "returns", "a", "promise", "which", "resolves", "to", "the", "response" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/crypto/index.js#L614-L642
7,703
matrix-org/matrix-js-sdk
src/models/event-timeline-set.js
EventTimelineSet
function EventTimelineSet(room, opts) { this.room = room; this._timelineSupport = Boolean(opts.timelineSupport); this._liveTimeline = new EventTimeline(this); // just a list - *not* ordered. this._timelines = [this._liveTimeline]; this._eventIdToTimeline = {}; this._filter = opts.filter |...
javascript
function EventTimelineSet(room, opts) { this.room = room; this._timelineSupport = Boolean(opts.timelineSupport); this._liveTimeline = new EventTimeline(this); // just a list - *not* ordered. this._timelines = [this._liveTimeline]; this._eventIdToTimeline = {}; this._filter = opts.filter |...
[ "function", "EventTimelineSet", "(", "room", ",", "opts", ")", "{", "this", ".", "room", "=", "room", ";", "this", ".", "_timelineSupport", "=", "Boolean", "(", "opts", ".", "timelineSupport", ")", ";", "this", ".", "_liveTimeline", "=", "new", "EventTimel...
Construct a set of EventTimeline objects, typically on behalf of a given room. A room may have multiple EventTimelineSets for different levels of filtering. The global notification list is also an EventTimelineSet, but lacks a room. <p>This is an ordered sequence of timelines, which may or may not be continuous. Eac...
[ "Construct", "a", "set", "of", "EventTimeline", "objects", "typically", "on", "behalf", "of", "a", "given", "room", ".", "A", "room", "may", "have", "multiple", "EventTimelineSets", "for", "different", "levels", "of", "filtering", ".", "The", "global", "notifi...
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/event-timeline-set.js#L62-L73
7,704
matrix-org/matrix-js-sdk
src/models/event.js
async function(crypto) { // start with a couple of sanity checks. if (!this.isEncrypted()) { throw new Error("Attempt to decrypt event which isn't encrypted"); } if ( this._clearEvent && this._clearEvent.content && this._clearEvent.content.msgtype...
javascript
async function(crypto) { // start with a couple of sanity checks. if (!this.isEncrypted()) { throw new Error("Attempt to decrypt event which isn't encrypted"); } if ( this._clearEvent && this._clearEvent.content && this._clearEvent.content.msgtype...
[ "async", "function", "(", "crypto", ")", "{", "// start with a couple of sanity checks.", "if", "(", "!", "this", ".", "isEncrypted", "(", ")", ")", "{", "throw", "new", "Error", "(", "\"Attempt to decrypt event which isn't encrypted\"", ")", ";", "}", "if", "(", ...
Start the process of trying to decrypt this event. (This is used within the SDK: it isn't intended for use by applications) @internal @param {module:crypto} crypto crypto module @returns {Promise} promise which resolves (to undefined) when the decryption attempt is completed.
[ "Start", "the", "process", "of", "trying", "to", "decrypt", "this", "event", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/event.js#L347-L379
7,705
matrix-org/matrix-js-sdk
src/models/event.js
function(crypto, userId) { const wireContent = this.getWireContent(); return crypto.requestRoomKey({ algorithm: wireContent.algorithm, room_id: this.getRoomId(), session_id: wireContent.session_id, sender_key: wireContent.sender_key, }, this.getKey...
javascript
function(crypto, userId) { const wireContent = this.getWireContent(); return crypto.requestRoomKey({ algorithm: wireContent.algorithm, room_id: this.getRoomId(), session_id: wireContent.session_id, sender_key: wireContent.sender_key, }, this.getKey...
[ "function", "(", "crypto", ",", "userId", ")", "{", "const", "wireContent", "=", "this", ".", "getWireContent", "(", ")", ";", "return", "crypto", ".", "requestRoomKey", "(", "{", "algorithm", ":", "wireContent", ".", "algorithm", ",", "room_id", ":", "thi...
Cancel any room key request for this event and resend another. @param {module:crypto} crypto crypto module @param {string} userId the user who received this event @returns {Promise} a promise that resolves when the request is queued
[ "Cancel", "any", "room", "key", "request", "for", "this", "event", "and", "resend", "another", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/event.js#L389-L397
7,706
matrix-org/matrix-js-sdk
src/models/event.js
function(userId) { // send the request to all of our own devices, and the // original sending device if it wasn't us. const wireContent = this.getWireContent(); const recipients = [{ userId, deviceId: '*', }]; const sender = this.getSender(); if (sende...
javascript
function(userId) { // send the request to all of our own devices, and the // original sending device if it wasn't us. const wireContent = this.getWireContent(); const recipients = [{ userId, deviceId: '*', }]; const sender = this.getSender(); if (sende...
[ "function", "(", "userId", ")", "{", "// send the request to all of our own devices, and the", "// original sending device if it wasn't us.", "const", "wireContent", "=", "this", ".", "getWireContent", "(", ")", ";", "const", "recipients", "=", "[", "{", "userId", ",", ...
Calculate the recipients for keyshare requests. @param {string} userId the user who received this event. @returns {Array} array of recipients
[ "Calculate", "the", "recipients", "for", "keyshare", "requests", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/event.js#L406-L420
7,707
matrix-org/matrix-js-sdk
src/models/event.js
function(decryptionResult) { this._clearEvent = decryptionResult.clearEvent; this._senderCurve25519Key = decryptionResult.senderCurve25519Key || null; this._claimedEd25519Key = decryptionResult.claimedEd25519Key || null; this._forwardingCurve25519KeyChain = ...
javascript
function(decryptionResult) { this._clearEvent = decryptionResult.clearEvent; this._senderCurve25519Key = decryptionResult.senderCurve25519Key || null; this._claimedEd25519Key = decryptionResult.claimedEd25519Key || null; this._forwardingCurve25519KeyChain = ...
[ "function", "(", "decryptionResult", ")", "{", "this", ".", "_clearEvent", "=", "decryptionResult", ".", "clearEvent", ";", "this", ".", "_senderCurve25519Key", "=", "decryptionResult", ".", "senderCurve25519Key", "||", "null", ";", "this", ".", "_claimedEd25519Key"...
Update the cleartext data on this event. (This is used after decrypting an event; it should not be used by applications). @internal @fires module:models/event.MatrixEvent#"Event.decrypted" @param {module:crypto~EventDecryptionResult} decryptionResult the decryption result, including the plaintext and some key info
[ "Update", "the", "cleartext", "data", "on", "this", "event", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/event.js#L538-L546
7,708
matrix-org/matrix-js-sdk
src/models/event.js
function(redaction_event) { // quick sanity-check if (!redaction_event.event) { throw new Error("invalid redaction_event in makeRedacted"); } // we attempt to replicate what we would see from the server if // the event had been redacted before we saw it. // ...
javascript
function(redaction_event) { // quick sanity-check if (!redaction_event.event) { throw new Error("invalid redaction_event in makeRedacted"); } // we attempt to replicate what we would see from the server if // the event had been redacted before we saw it. // ...
[ "function", "(", "redaction_event", ")", "{", "// quick sanity-check", "if", "(", "!", "redaction_event", ".", "event", ")", "{", "throw", "new", "Error", "(", "\"invalid redaction_event in makeRedacted\"", ")", ";", "}", "// we attempt to replicate what we would see from...
Update the content of an event in the same way it would be by the server if it were redacted before it was sent to us @param {module:models/event.MatrixEvent} redaction_event event causing the redaction
[ "Update", "the", "content", "of", "an", "event", "in", "the", "same", "way", "it", "would", "be", "by", "the", "server", "if", "it", "were", "redacted", "before", "it", "was", "sent", "to", "us" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/event.js#L647-L684
7,709
matrix-org/matrix-js-sdk
src/models/event-timeline.js
EventTimeline
function EventTimeline(eventTimelineSet) { this._eventTimelineSet = eventTimelineSet; this._roomId = eventTimelineSet.room ? eventTimelineSet.room.roomId : null; this._events = []; this._baseIndex = 0; this._startState = new RoomState(this._roomId); this._startState.paginationToken = null; t...
javascript
function EventTimeline(eventTimelineSet) { this._eventTimelineSet = eventTimelineSet; this._roomId = eventTimelineSet.room ? eventTimelineSet.room.roomId : null; this._events = []; this._baseIndex = 0; this._startState = new RoomState(this._roomId); this._startState.paginationToken = null; t...
[ "function", "EventTimeline", "(", "eventTimelineSet", ")", "{", "this", ".", "_eventTimelineSet", "=", "eventTimelineSet", ";", "this", ".", "_roomId", "=", "eventTimelineSet", ".", "room", "?", "eventTimelineSet", ".", "room", ".", "roomId", ":", "null", ";", ...
Construct a new EventTimeline <p>An EventTimeline represents a contiguous sequence of events in a room. <p>As well as keeping track of the events themselves, it stores the state of the room at the beginning and end of the timeline, and pagination tokens for going backwards and forwards in the timeline. <p>In order t...
[ "Construct", "a", "new", "EventTimeline" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/event-timeline.js#L44-L61
7,710
matrix-org/matrix-js-sdk
src/content-repo.js
function(baseUrl, mxc, width, height, resizeMethod, allowDirectLinks) { if (typeof mxc !== "string" || !mxc) { return ''; } if (mxc.indexOf("mxc://") !== 0) { if (allowDirectLinks) { return mxc; } else { ...
javascript
function(baseUrl, mxc, width, height, resizeMethod, allowDirectLinks) { if (typeof mxc !== "string" || !mxc) { return ''; } if (mxc.indexOf("mxc://") !== 0) { if (allowDirectLinks) { return mxc; } else { ...
[ "function", "(", "baseUrl", ",", "mxc", ",", "width", ",", "height", ",", "resizeMethod", ",", "allowDirectLinks", ")", "{", "if", "(", "typeof", "mxc", "!==", "\"string\"", "||", "!", "mxc", ")", "{", "return", "''", ";", "}", "if", "(", "mxc", ".",...
Get the HTTP URL for an MXC URI. @param {string} baseUrl The base homeserver url which has a content repo. @param {string} mxc The mxc:// URI. @param {Number} width The desired width of the thumbnail. @param {Number} height The desired height of the thumbnail. @param {string} resizeMethod The thumbnail resize method to...
[ "Get", "the", "HTTP", "URL", "for", "an", "MXC", "URI", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/content-repo.js#L37-L77
7,711
matrix-org/matrix-js-sdk
src/content-repo.js
function(baseUrl, identiconString, width, height) { if (!identiconString) { return null; } if (!width) { width = 96; } if (!height) { height = 96; } const params = { width: width, height: height, ...
javascript
function(baseUrl, identiconString, width, height) { if (!identiconString) { return null; } if (!width) { width = 96; } if (!height) { height = 96; } const params = { width: width, height: height, ...
[ "function", "(", "baseUrl", ",", "identiconString", ",", "width", ",", "height", ")", "{", "if", "(", "!", "identiconString", ")", "{", "return", "null", ";", "}", "if", "(", "!", "width", ")", "{", "width", "=", "96", ";", "}", "if", "(", "!", "...
Get an identicon URL from an arbitrary string. @param {string} baseUrl The base homeserver url which has a content repo. @param {string} identiconString The string to create an identicon for. @param {Number} width The desired width of the image in pixels. Default: 96. @param {Number} height The desired height of the im...
[ "Get", "an", "identicon", "URL", "from", "an", "arbitrary", "string", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/content-repo.js#L87-L108
7,712
matrix-org/matrix-js-sdk
src/store/memory.js
function(room) { this.rooms[room.roomId] = room; // add listeners for room member changes so we can keep the room member // map up-to-date. room.currentState.on("RoomState.members", this._onRoomMember.bind(this)); // add existing members const self = this; room.cu...
javascript
function(room) { this.rooms[room.roomId] = room; // add listeners for room member changes so we can keep the room member // map up-to-date. room.currentState.on("RoomState.members", this._onRoomMember.bind(this)); // add existing members const self = this; room.cu...
[ "function", "(", "room", ")", "{", "this", ".", "rooms", "[", "room", ".", "roomId", "]", "=", "room", ";", "// add listeners for room member changes so we can keep the room member", "// map up-to-date.", "room", ".", "currentState", ".", "on", "(", "\"RoomState.membe...
Store the given room. @param {Room} room The room to be stored. All properties must be stored.
[ "Store", "the", "given", "room", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/memory.js#L113-L123
7,713
matrix-org/matrix-js-sdk
src/store/memory.js
function(event, state, member) { if (member.membership === "invite") { // We do NOT add invited members because people love to typo user IDs // which would then show up in these lists (!) return; } const user = this.users[member.userId] || new User(member.use...
javascript
function(event, state, member) { if (member.membership === "invite") { // We do NOT add invited members because people love to typo user IDs // which would then show up in these lists (!) return; } const user = this.users[member.userId] || new User(member.use...
[ "function", "(", "event", ",", "state", ",", "member", ")", "{", "if", "(", "member", ".", "membership", "===", "\"invite\"", ")", "{", "// We do NOT add invited members because people love to typo user IDs", "// which would then show up in these lists (!)", "return", ";", ...
Called when a room member in a room being tracked by this store has been updated. @param {MatrixEvent} event @param {RoomState} state @param {RoomMember} member
[ "Called", "when", "a", "room", "member", "in", "a", "room", "being", "tracked", "by", "this", "store", "has", "been", "updated", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/memory.js#L132-L152
7,714
matrix-org/matrix-js-sdk
src/store/memory.js
function(filter) { if (!filter) { return; } if (!this.filters[filter.userId]) { this.filters[filter.userId] = {}; } this.filters[filter.userId][filter.filterId] = filter; }
javascript
function(filter) { if (!filter) { return; } if (!this.filters[filter.userId]) { this.filters[filter.userId] = {}; } this.filters[filter.userId][filter.filterId] = filter; }
[ "function", "(", "filter", ")", "{", "if", "(", "!", "filter", ")", "{", "return", ";", "}", "if", "(", "!", "this", ".", "filters", "[", "filter", ".", "userId", "]", ")", "{", "this", ".", "filters", "[", "filter", ".", "userId", "]", "=", "{...
Store a filter. @param {Filter} filter
[ "Store", "a", "filter", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/memory.js#L243-L251
7,715
matrix-org/matrix-js-sdk
src/store/memory.js
function(userId, filterId) { if (!this.filters[userId] || !this.filters[userId][filterId]) { return null; } return this.filters[userId][filterId]; }
javascript
function(userId, filterId) { if (!this.filters[userId] || !this.filters[userId][filterId]) { return null; } return this.filters[userId][filterId]; }
[ "function", "(", "userId", ",", "filterId", ")", "{", "if", "(", "!", "this", ".", "filters", "[", "userId", "]", "||", "!", "this", ".", "filters", "[", "userId", "]", "[", "filterId", "]", ")", "{", "return", "null", ";", "}", "return", "this", ...
Retrieve a filter. @param {string} userId @param {string} filterId @return {?Filter} A filter or null.
[ "Retrieve", "a", "filter", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/memory.js#L259-L264
7,716
matrix-org/matrix-js-sdk
src/store/memory.js
function(events) { const self = this; events.forEach(function(event) { self.accountData[event.getType()] = event; }); }
javascript
function(events) { const self = this; events.forEach(function(event) { self.accountData[event.getType()] = event; }); }
[ "function", "(", "events", ")", "{", "const", "self", "=", "this", ";", "events", ".", "forEach", "(", "function", "(", "event", ")", "{", "self", ".", "accountData", "[", "event", ".", "getType", "(", ")", "]", "=", "event", ";", "}", ")", ";", ...
Store user-scoped account data events. N.B. that account data only allows a single event per type, so multiple events with the same type will replace each other. @param {Array<MatrixEvent>} events The events to store.
[ "Store", "user", "-", "scoped", "account", "data", "events", ".", "N", ".", "B", ".", "that", "account", "data", "only", "allows", "a", "single", "event", "per", "type", "so", "multiple", "events", "with", "the", "same", "type", "will", "replace", "each"...
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/memory.js#L301-L306
7,717
matrix-org/matrix-js-sdk
spec/integ/matrix-client-event-timeline.spec.js
startClient
function startClient(httpBackend, client) { httpBackend.when("GET", "/pushrules").respond(200, {}); httpBackend.when("POST", "/filter").respond(200, { filter_id: "fid" }); httpBackend.when("GET", "/sync").respond(200, INITIAL_SYNC_DATA); client.startClient(); // set up a promise which will resolve...
javascript
function startClient(httpBackend, client) { httpBackend.when("GET", "/pushrules").respond(200, {}); httpBackend.when("POST", "/filter").respond(200, { filter_id: "fid" }); httpBackend.when("GET", "/sync").respond(200, INITIAL_SYNC_DATA); client.startClient(); // set up a promise which will resolve...
[ "function", "startClient", "(", "httpBackend", ",", "client", ")", "{", "httpBackend", ".", "when", "(", "\"GET\"", ",", "\"/pushrules\"", ")", ".", "respond", "(", "200", ",", "{", "}", ")", ";", "httpBackend", ".", "when", "(", "\"POST\"", ",", "\"/fil...
start the client, and wait for it to initialise
[ "start", "the", "client", "and", "wait", "for", "it", "to", "initialise" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/matrix-client-event-timeline.spec.js#L77-L98
7,718
matrix-org/matrix-js-sdk
src/store/indexeddb-local-backend.js
selectQuery
function selectQuery(store, keyRange, resultMapper) { const query = store.openCursor(keyRange); return new Promise((resolve, reject) => { const results = []; query.onerror = (event) => { reject(new Error("Query failed: " + event.target.errorCode)); }; // collect resul...
javascript
function selectQuery(store, keyRange, resultMapper) { const query = store.openCursor(keyRange); return new Promise((resolve, reject) => { const results = []; query.onerror = (event) => { reject(new Error("Query failed: " + event.target.errorCode)); }; // collect resul...
[ "function", "selectQuery", "(", "store", ",", "keyRange", ",", "resultMapper", ")", "{", "const", "query", "=", "store", ".", "openCursor", "(", "keyRange", ")", ";", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "const"...
Helper method to collect results from a Cursor and promiseify it. @param {ObjectStore|Index} store The store to perform openCursor on. @param {IDBKeyRange=} keyRange Optional key range to apply on the cursor. @param {Function} resultMapper A function which is repeatedly called with a Cursor. Return the data you want to...
[ "Helper", "method", "to", "collect", "results", "from", "a", "Cursor", "and", "promiseify", "it", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/indexeddb-local-backend.js#L61-L79
7,719
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
7,720
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
7,721
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
7,722
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
7,723
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
7,724
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
7,725
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
7,726
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
7,727
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
7,728
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
7,729
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
7,730
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
7,731
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
7,732
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
7,733
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
7,734
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
7,735
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
7,736
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
7,737
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
7,738
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
7,739
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
7,740
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
7,741
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
7,742
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
7,743
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
7,744
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
7,745
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
7,746
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
7,747
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
7,748
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
7,749
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
7,750
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
7,751
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
7,752
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
7,753
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
7,754
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
7,755
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
7,756
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
7,757
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
7,758
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
7,759
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
7,760
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
7,761
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
7,762
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
7,763
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
7,764
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
7,765
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
7,766
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
7,767
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
7,768
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
7,769
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
7,770
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
7,771
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
7,772
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
7,773
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
7,774
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
7,775
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
7,776
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
7,777
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
7,778
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
7,779
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
7,780
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
7,781
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
7,782
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
7,783
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
7,784
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
7,785
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
7,786
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
7,787
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
7,788
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
7,789
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
7,790
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
7,791
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
7,792
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
7,793
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
7,794
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
7,795
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
7,796
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
7,797
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
7,798
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
7,799
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