An enhanced version of `typeof` that handles arrays and dates as well.
343442
function type(value) {
  let valueType = typeof value;
  if (Array.isArray(value)) {
    valueType = 'array';
  } else if (value instanceof Date) {
    valueType = 'date';
  } else if (value === null) {
    valueType = 'null';
  }

  return valueType;
}
422864
def dateDict(date, prefix = ""):
    """"""
    res = {}

    res[prefix+"a"] = date.strftime("%a")
    res[prefix+"A"] = date.strftime("%A")
    res[prefix+"b"] = date.strftime("%b")
    res[prefix+"B"] = date.strftime("%B")
    res[prefix+"c"] = date.strftime("%c")
    res[prefix+"d"] = date.strftime("%d")
    res[prefix+"H"] = date.strftime("%H")
    res[prefix+"I"] = date.strftime("%I")
    res[prefix+"j"] = date.strftime("%j")
    res[prefix+"m"] = date.strftime("%m")
    res[prefix+"M"] = date.strftime("%M")
    res[prefix+"p"] = date.strftime("%p")
    res[prefix+"S"] = date.strftime("%S")
    res[prefix+"U"] = date.strftime("%U")
    res[prefix+"w"] = date.strftime("%w")
    res[prefix+"W"] = date.strftime("%W")
    res[prefix+"x"] = date.strftime("%x")
    res[prefix+"X"] = date.strftime("%X")
    res[prefix+"y"] = date.strftime("%y")
    res[prefix+"Y"] = date.strftime("%Y")
    res[prefix+"Z"] = date.strftime("%Z")

    for i, value in res.items():
        res[i] = locale_to_utf8(value)

    return res
1000430
function checkType(type,value){
             if(type){
                 if(typeof type == 'string' && type != 'any' &&
                         (type == 'null' ? value !== null : typeof value != type) &&
                         !(value instanceof Array && type == 'array') &&
                         !(value instanceof Date && type == 'date') &&
                         !(type == 'integer' && value%1===0)){
                     return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}];
                 }
                 if(type instanceof Array){
                     var unionErrors=[];
                     for(var j = 0; j < type.length; j++){ // a union type
                         if(!(unionErrors=checkType(type[j],value)).length){
                             break;
                         }
                     }
                     if(unionErrors.length){
                         return unionErrors;
                     }
                 }else if(typeof type == 'object'){
                     var priorErrors = errors;
                     errors = [];
                     checkProp(value,type,path);
                     var theseErrors = errors;
                     errors = priorErrors;
                     return theseErrors;
                 }
             }
             return [];
         }
223966
function(a, b) {
        var self = this;

        function compareArrays(a, b) {
            if (a.length !== b.length) {
                return a.length < b.length ? -1 : 1;
            } else {
                for (var i = 0; i < a.length ; i++) {
                    var compareResult = self.compare(a[i], b[i]);
                    if (compareResult !== 0) {
                        return compareResult;
                    }
                }
                return 0;
            }
        }

        var typeA = this.typeOf(a);
        var typeB = this.typeOf(b);

        if (typeA !== typeB) {
            throw typeErrorIncomparable(a, b);
        }

        switch (typeA) {
            case 'Number':
            case 'String':
                return a === b ? 0 : (a > b ? 1 : -1);

            case 'Date':
            case 'Duration':
                return JuttleMoment.compare(a, b);

            case 'Array':
                return compareArrays(a, b);

            default:
                throw typeErrorIncomparable(a, b);
        }

    }
249338
function since(date) {
  if (typeof date !== 'object') {
    return date
  } else if (date.getTime) {
    return Math.floor(date.getTime() / 1000)
  }
  throw TypeError('Expected a date or number')
}
1304478
function typeOf(value) {
            var s = typeof value;
            if(s === 'object') {
                if(value) {
                    if(value instanceof Array) {
                        s = 'array';
                    }
                } else {
                    s = 'null';
                }
            }
            return s;
        }
468465
function (a, b, /*internal use*/mismatchKeys, /*internal use*/mismatchValues) {
                // inspired by jasmine
                mismatchKeys = mismatchKeys || [];
                mismatchValues = mismatchValues || [];

                if (a === b) {
                    return TRUE;
                }
                if (a === undefined || a === null || b === undefined || b === null) {
                    // need type coercion
                    return a == null && b == null;
                }
                if (a instanceof Date && b instanceof Date) {
                    return a.getTime() == b.getTime();
                }
                if (typeof a == 'string' && typeof b == 'string') {
                    return (a == b);
                }
                if (typeof a==='number' && typeof b==='number') {
                    return (a == b);
                }
                if (typeof a === 'object' && typeof b === 'object') {
                    return compareObjects(a, b, mismatchKeys, mismatchValues);
                }
                // Straight check
                return (a === b);
            }
297324
function parseTypeArray (type) {
  var tmp = type.match(/(.*)\[(.*?)\]$/)
  if (tmp) {
    return tmp[2] === '' ? 'dynamic' : parseInt(tmp[2], 10)
  }
  return null
}
904159
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;
        result.buffer = result;
        result.byteLength = result.length;
        result.set = set_;
        if (typeof arg1 === 'object' && arg1.buffer) {
            result.buffer = arg1.buffer;
        }

        return result;
    }
1007896
function dateList(numbers, type) {
    if (numbers.length < 2) {
      return numberToDateName('' + numbers[0], type);
    }

    var lastVal = '' + numbers.pop();
    var outputText = '';

    for (var i = 0, value; value = numbers[i]; i++) {
      if (outputText.length > 0) {
        outputText += ', ';
      }
      outputText += numberToDateName(value, type);
    }
    return outputText + ` ${locale['and']} ` + numberToDateName(lastVal, type);
  }
1238058
function date(value) {
  var parsedDate = Date.parse(value);

  // couldn't parse it
  if (typeOf(parsedDate) != 'number') {
    return throwModifierError('date', value, {message: 'Invalid Date'});
  }

  return new Date(parsedDate);
}
1168335
function() {
        var returnDates = [],
            selected = this.cfg.getProperty(DEF_CFG.SELECTED.key);

        for (var d=0;d<selected.length;++d) {
            var dateArray = selected[d];

            var date = DateMath.getDate(dateArray[0],dateArray[1]-1,dateArray[2]);
            returnDates.push(date);
        }

        returnDates.sort( function(a,b) { return a-b; } );
        return returnDates;
    }
498197
private SortedSet<Date> readDates(JSONValue json) {

        JSONArray array = null == json ? null : json.isArray();
        if (null != array) {
            SortedSet<Date> result = new TreeSet<>();
            for (int i = 0; i < array.size(); i++) {
                Date d = readOptionalDate(array.get(i));
                if (null != d) {
                    result.add(d);
                }
            }
            return result;
        }
        return new TreeSet<>();
    }
341207
private static void checkDateElements(List<Vertex> linkedArray)
    {
        if (linkedArray.size() < 2)
            return;
        ListIterator<Vertex> listIterator = linkedArray.listIterator();
        Vertex next = listIterator.next();
        Vertex current = next;
        while (listIterator.hasNext())
        {
            next = listIterator.next();
            if (TextUtility.isAllNum(current.realWord) || TextUtility.isAllChineseNum(current.realWord))
            {
                //===== 1、如果当前词是数字，下一个词是“月、日、时、分、秒、月份”中的一个，则合并且当前词词性是时间
                String nextWord = next.realWord;
                if ((nextWord.length() == 1 && "月日时分秒".contains(nextWord)) || (nextWord.length() == 2 && nextWord.equals("月份")))
                {
                    mergeDate(listIterator, next, current);
                }
                //===== 2、如果当前词是可以作为年份的数字，下一个词是“年”，则合并，词性为时间，否则为数字。
                else if (nextWord.equals("年"))
                {
                    if (TextUtility.isYearTime(current.realWord))
                    {
                        mergeDate(listIterator, next, current);
                    }
                    //===== 否则当前词就是数字了 =====
                    else
                    {
                        current.confirmNature(Nature.m);
                    }
                }
                else
                {
                    //===== 3、如果最后一个汉字是"点" ，则认为当前数字是时间
                    if (current.realWord.endsWith("点"))
                    {
                        current.confirmNature(Nature.t, true);
                    }
                    else
                    {
                        char[] tmpCharArray = current.realWord.toCharArray();
                        String lastChar = String.valueOf(tmpCharArray[tmpCharArray.length - 1]);
                        //===== 4、如果当前串最后一个汉字不是"∶·．／"和半角的'.''/'，那么是数
                        if (!"∶·．／./".contains(lastChar))
                        {
                            current.confirmNature(Nature.m, true);
                        }
                        //===== 5、当前串最后一个汉字是"∶·．／"和半角的'.''/'，且长度大于1，那么去掉最后一个字符。例如"1."
                        else if (current.realWord.length() > 1)
                        {
                            char last = current.realWord.charAt(current.realWord.length() - 1);
                            current = Vertex.newNumberInstance(current.realWord.substring(0, current.realWord.length() - 1));
                            listIterator.previous();
                            listIterator.previous();
                            listIterator.set(current);
                            listIterator.next();
                            listIterator.add(Vertex.newPunctuationInstance(String.valueOf(last)));
                        }
                    }
                }
            }
            current = next;
        }
//        logger.trace("日期识别后：" + Graph.parseResult(linkedArray));
    }
626653
def save_array_types(self, fname):
    '''
    '''
    type_defs = {'arrays': sorted(list(self.array_types))}
    with open(fname, 'wt') as fh:
      pprint(type_defs, stream=fh)
133288
function filterYMDDay(arr, disabledDateObj) {
  const newArr = [];
  const parseYMDValue = (value) => {
    const date = [];
    date[0] = (`${value}`).substring(0, 4);
    date[1] = (`${value}`).substring(4, 6) - 1;
    date[2] = (`${value}`).substring(6, 8);
    return new Date(...date).getTime();
  };
  const minDate = parseYMDValue(arr[0].value);
  const maxDate = parseYMDValue(arr[arr.length - 1].value);
  const dayRangeArr = getDateRangeArr(parseDisabledArr(disabledDateObj), minDate, maxDate);
  arr.forEach((item) => {
    const value = parseYMDValue(item.value);
    let shouldPass = true;
    for (let i = 0; i < dayRangeArr.length; i++) {
      const dis = dayRangeArr[i];
      const { start, end } = dis;
      if (value >= new Date(start).getTime() && value <= new Date(end).getTime()) {
        shouldPass = false;
        break;
      }
    }
    if (shouldPass) {
      newArr.push(item);
    }
  });
  return newArr;
}
226423
function mapArray(type) {
		return Array.map(type, function(thing) {
			return isType(thing) ? parse(thing) : thing;
		});
	}