Skip to content

Instantly share code, notes, and snippets.

@cherifGsoul
Last active July 6, 2018 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cherifGsoul/efd28782e6b1a359019e91c80386c587 to your computer and use it in GitHub Desktop.
Save cherifGsoul/efd28782e6b1a359019e91c80386c587 to your computer and use it in GitHub Desktop.
can-util replacements

can-util for can namespace

replaced by can-namespace

can-util/js/each/each

  • when looping on objects replaced by can-reflect.eachKey
  • when looping on lists/arrays replaced by can-reflect.each
  • can-reflect.eachKey has better performance

can-util/js/is-promise/is-promise

replaced by can-reflect.isPromise

can-util/js/make-array/make-array

replaced by can-reflect.toArray

can-util/js/is-empty-object/is-empty-object

replaced by can-reflect.size which can be used like the following:

import canReflect from 'can-reflect';
const isEmptyObject = (val) => canReflect.size(val) === 0;

can-util/js/is-plain-object/is-plain-object

replaced by can-reflect-isPlainObject

can-util/js/deep-assign/deep-assign

replaced by can-relfect.assignDeep

can-util/js/cid-map/cid-map

replaced by can-cid/map/map

can-util/js/cid-set/cid-set

replaced bycan-cid/set/set

can-util/dom/dispatch/dispatch

replaced by can-dom-events.dispatch it was used domDispatch.call(input, "input"); now we use can-dom-events.dispatch in simpler way:

import domEvents from "can-dom-events";
domEvents.dispatch(input, "input");

input is the target object (event dispatcher) and "input" is the event type

can-util/js/assign/assign

replaced by can-assign

can-util/js/get/get

replaced by can-key/get/get

can-util/js/diff-object/diff-object

replaced by can-diff:

  • can-diff/map/map: for objects (maps).
  • can-diff/list/list: for list of objects (list of maps).
  • the can-utildiff object contains objects with propertykey this was changed with can-diff, property key is replaced with key

can-util/js/string/string

replaced by can-string

  • However the function string.sub is repalced can-key/sub/sub

can-util/js/string-to-any/string-to-any

replaced by can-string-to-any

can-util/js/single-reference/single-reference

replaced by can-single-reference

can-util/js/dev/dev

replaced by can-log/dev/dev

can-util/js/global/global

replaced by can-globals/global/global

can-util/dom/child-nodes/child-nodes

replaced by can-child-nodes

can-util/js/import/import

replaced by can-import-module

can-util/dom/fragment/fragment

replaced by can-fragment

can-util/dom/frag/frag

replaced by can-fragment

import frag from "can-fragment"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment