Skip to content

Instantly share code, notes, and snippets.

@hyle
Last active May 14, 2022 21:15
Show Gist options
  • Star 90 You must be signed in to star a gist
  • Fork 24 You must be signed in to fork a gist
  • Save hyle/1180607 to your computer and use it in GitHub Desktop.
Save hyle/1180607 to your computer and use it in GitHub Desktop.
KnockoutJS utils (ko.utils) signatures
// knockout 2.2.1
ko.utils.arrayFilter = function (array, predicate) { /* .. */ }
ko.utils.arrayFirst = function (array, predicate, predicateOwner) { /* .. */ }
ko.utils.arrayForEach = function (array, action) { /* .. */ }
ko.utils.arrayGetDistinctValues = function (array) { /* .. */ }
ko.utils.arrayIndexOf = function (array, item) { /* .. */ }
ko.utils.arrayMap = function (array, mapping) { /* .. */ }
ko.utils.arrayPushAll = function (array, valuesToPush) { /* .. */ }
ko.utils.arrayRemoveItem = function (array, itemToRemove) { /* .. */ }
ko.utils.cloneNodes = function (nodesArray, shouldCleanNodes) { /* .. */ }
ko.utils.compareArrays = function compareArrays(oldArray, newArray, dontLimitMoves) { /* .. */ }
ko.utils.domNodeIsAttachedToDocument = function (node) { /* .. */ }
ko.utils.domNodeIsContainedBy = function (node, containedByNode) { /* .. */ }
ko.utils.emptyDomNode = function (domNode) { /* .. */ }
ko.utils.ensureSelectElementIsRenderedCorrectly = function (selectElement) { /* .. */ }
ko.utils.extend = function (target, source) { /* .. */ }
ko.utils.forceRefresh = function (node) { /* .. */ }
ko.utils.getFormFields = function (form, fieldName) { /* .. */ }
ko.utils.makeArray = function (arrayLikeObject) { /* .. */ }
ko.utils.moveCleanedNodesToContainerElement = function (nodes) { /* .. */ }
ko.utils.parseHtmlFragment = function (html) { /* .. */ }
ko.utils.parseJson = function (jsonString) { /* .. */ }
ko.utils.peekObservable = function (value) { /* .. */ }
ko.utils.postJson = function (urlOrForm, data, options) { /* .. */ }
ko.utils.range = function (min, max) { /* .. */ }
ko.utils.registerEventHandler = function (element, eventType, handler) { /* .. */ }
ko.utils.replaceDomNodes = function (nodeToReplaceOrNodeArray, newNodesArray) { /* .. */ }
ko.utils.setDomNodeChildren = function (domNode, childNodes) { /* .. */ }
ko.utils.setDomNodeChildrenFromArrayMapping = function (domNode, array, mapping, options, callbackAfterAddingNodes) { /* .. */ }
ko.utils.setElementName = function (element, name) { /* .. */ }
ko.utils.setHtml = function (node, html) { /* .. */ }
ko.utils.setOptionNodeSelectionState = function (optionNode, isSelected) { /* .. */ }
ko.utils.setTextContent = function (element, textContent) { /* .. */ }
ko.utils.stringStartsWith = function (string, startsWith) { /* .. */ }
ko.utils.stringTokenize = function (string, delimiter) { /* .. */ }
ko.utils.stringTrim = function (string) { /* .. */ }
ko.utils.stringifyJson = function (data, replacer, space) { // replacer and space are optional /* .. */ }
ko.utils.tagNameLower = function (element) { /* .. */ }
ko.utils.toggleDomNodeCssClass = function (node, classNames, shouldHaveClass) { /* .. */ }
ko.utils.triggerEvent = function (element, eventType) { /* .. */ }
ko.utils.unwrapObservable = function (value) { /* .. */ }
@hyle
Copy link
Author

hyle commented Sep 25, 2018

@LeonSilva15
Copy link

Thank you!

@ScottA38
Copy link

Hi, thankyou for the resource - I am not sure if there is somewhere else to find it but I would appreciate it if the primitive retturn types could be included as well for each sig

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment