Skip to content

core_function

j-show edited this page Feb 28, 2019 · 1 revision

Core function library, mainly used for the identification and judgment of types.

type(obj, [detail=false])

  • Note
    • Type recognition, which returns the target type in the form of a string
  • Parameters
    • obj Detect objects, which can be of any type
    • detail=false Whether to perform depth recognition
  • Return
    • Return string,return the target type by string form
    • detail=false,reference types are recognized as object
    • detail=true,name recognition for reference types

is(a,b,[abs=true])

  • Note
    • Determine if the object is equal
  • Parameters
    • ab Detect objects, which can be of any type
    • abs=true Determine absolute equality when judging reference types (each data content is judged in depth)
  • Return
    • Return true/false

isSimple(value)

  • Note
    • Determine if the object is a simple type
  • Parameters
    • value Detect objects, which can be of any type
  • Return
    • Return true/false
    • boolean/number/string,belonging to a simple type
    • null/undefined,belonging to a simple type

isNull(value, [opt])

  • Note
    • Determine if the object is null
  • Parameters
    • value Detect objects, which can be of any type
    • opt Detecting parameters
      • opt.udf=true Whether to count undefined as null
      • opt.obj=false Whether the array/object is empty is null
      • opt is boolean,equivalent opt.udf
  • Return
    • Return true/false

isBool(value, [str=false])

  • Note
    • Determine if the object is Boolean
  • Parameters
    • value Detect objects, which can be of any type
    • str Whether to judge strings
      • str=true,Forces value to be converted to string determination
  • Return
    • Return true/false

isNumber(value, [opt])

  • Note
    • Determine if the object is a number
  • Parameters
    • value Detect objects, which can be of any type
    • opt Detecting parameters
      • opt.nan=false Whether to count Nan as a number
      • opt.str=false Whether to convert strings to numeric judgments
      • opt.int=true Whether to recognize only integers
      • opt.min=NaN Number less than min, not counted as numbers
      • opt.max=NaN Number greater than Max, not counted as numbers
      • opt is boolean,equivalent opt.nan
  • Return
    • Return true/false
    • opt.int=false,Floating-point numbers are recognized, and scientific notation can be identified when opt.str=true at the same time

isString(value, [empty=false])

  • Note
    • Determine if the object is string
  • Parameters
    • value Detect objects, which can be of any type
    • empty=false Whether an empty string is a string
  • Return
    • Return true/false

isFunction(value, [type])

  • Note
    • Determine whether an object is function
  • Parameters
    • value Detect objects, which can be of any type
    • type Detecting parameters
      • type=true,async/generator is not function
      • type can be valued as 'async', 'generator', at which point strict judgment types
  • Return
    • Return true/false

isArray(value, [arg=false])

  • Note
    • Determine whether an object is an array
  • Parameters
    • value Detect objects, which can be of any type
    • arg=false Whether the arguments object counts as an array
  • Return
    • Return true/false

isObject(value, [arg])

  • Note
    • Determines whether an object is objects and can be used to distinguish whether it is a JSON data object
  • Parameters
    • value Detect objects, which can be of any type
    • arg Detecting parameters
      • Default only recognition, basic object
      • arg='any'/true Any reference type counts as Object
      • arg=false Any reference type is not equal to null is Object
  • Return
    • Return true/false

isPromise(value)

  • Note
    • Determine if the object is an Promise object
  • Parameters
    • value Detect objects, which can be of any type
  • Return
    • Return true/false

isGenerator(value, [obj=false])

  • Note
    • Determine whether the object is generator, and both functions and objects return true
  • Parameters
    • value Detect objects, which can be of any type
    • obj=false Whether to detect generator objects
  • Return
    • Return true/false

isJSON(value)

  • Note
    • Determine if the object is a JSON object
  • Parameters
    • value Detect objects, which can be of any type
  • Return
    • Return true/false

isjQuery(value)

  • Note
    • Determine if the object is a jquery object
  • Parameters
    • value Detect objects, which can be of any type
  • Return
    • Return true/false

isDOM(value)

  • Note
    • Determine if the object is a DOM object
  • Parameters
    • value Detect objects, which can be of any type
  • Return
    • Return true/false

isDate(value, [str=false])

  • Note
    • Determine if the object is an Dete object
  • Parameters
    • value Detect objects, which can be of any type
    • str=false Whether to recognize string content
      • str=true,will perform string content parsing
  • Return
    • Return true/false

isTime(value, [str=false])

  • Note
    • Determines whether an object is a Date object that contains time
  • Parameters
    • value Detect objects, which can be of any type
    • str=false Whether to recognize string content
      • str=true,String content parsing, and the content must contain a time format
  • Return
    • Return true/false

isGuid(value)

  • Note
    • Determine if the object is a GUID
  • Parameters
    • value Detect objects, which can be of any type
      • value=string,will perform content parsing
      • Value values must conform to GUID rules
  • Return
    • Return true/false

between(value, b1, b2)

  • Note
    • Determine whether the numbers are b1,b2 between
  • Parameters
    • value Detect objects, which can be of any type
    • b1b2 Source of Judgment
  • Return
    • Return true/false
    • This function is an unsafe function and will be perfected in subsequent versions

callback(value, [index=0])

  • Note
    • Gets the callback function in the object
  • Parameters
    • value Detection object, which can be an array or arguments object
    • index=0 Exclude the number of parameters
      • The function assumes that the last item of the detection object is a callback function, which is used to distinguish the number of parameters indexparameters when the decision is ignored
  • Return
    • Return function

each(value, callback, [opt])

  • Note
    • Object Traversal function
  • Parameters
    • value Traversing an object, which can be a array|object|string|set|map type
    • callback(item, index, type, list) Traversal function
      • item Traversing content
      • index Traversal serial Number,value=object,index is key
      • type Traversing content Types,opt.detail=true, item is value type
      • list Real Traversal objects,opt.desc=true,Traversing an object is not equal to a real traversal object
      • When the traversal function returns to false inside, the traversal can be interrupted
    • opt Detecting parameters
      • opt.detail=false Whether to identify traversal content types
      • opt.force=false Whether to force the use of array recognition
      • opt.index=0 Start traversal position, effective when value=array/string
      • opt.desc=false Whether in reverse order, effective when value=array/string
      • opt=boolean,equivalent opt.detail
      • opt=number,equivalent opt.index
  • Return
    • Return true/false,Whether to traverse complete
    • Unable to traverse object or traverse interrupt, will return false

unique(value, [write=false])

  • Note
    • unique function
  • Parameters
    • value Detection object must be an array object
    • write=false Whether to change the detection object
      • write=true,Will overwrite the value content, the reference remains the same
  • Return
    • Return array,has been de-reset the array

has(value, list, [callback])

  • Note
    • Determines whether an object is contained within a list object
  • Parameters
    • value Detect objects, which can be of any type
    • list Detection list, which can be array/object/set/map object
    • callback Triggers a callback function when detection exists
  • Return
    • Return true/false

clone(src, dest, [opt])

  • Note
    • Secure copy function
  • Parameters
    • src Copy sources, which can be of any type
    • dest Copy targets, which can be of any type
    • opt Detecting parameters
      • opt.deep=false Deep copy, and whether to merge content when the copy target is a reference type
      • opt.write=true Whether to rewrite dest
        • opt.write=true,Will overwrite the dest content, the reference remains the same
  • Return
    • Return Final copy content, type determined by src and dest