0.1.0 • Published 3 years ago

@langnang/js v0.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

JavaScript

目录

Algorithm

Sort

  1. bubbleSort(numberArray): 冒泡排序
  2. bucketSort(numberArray): 桶排序
  3. countingSort(numberArray): 技术排序
  4. heapSort(numberArray): 堆排序
  5. insertionSort(numberArray): 插入排序
  6. mergeSort(numberArray): 归并排序
  7. quickSort(numberArray): 快速排序
  8. radixSort(numberArray): 基数排序
  9. selectionSort(numberArray): 选择排序
  10. shellSort(numberArray): 希尔排序

Math

  1. factorial(number): 阶乘。所有小于及等于该数的正整数的积,并且 1 的阶乘为 1。自然数 n 的阶乘写作 n!。
  2. euclideanAlgorithm(a, b): 欧几里得算法。指用于计算两个非负整数 a,b 的最大公约数

Array

  • : Array.prototype.copyWithin()
  • : Array.prototype.entries()
  • : Array.prototype.flat()
  • : Array.prototype.flatMap()
  1. ArrayFrom(): Array.from()
  2. ArrayIs(): Array.isArray()
  3. ArrayOf(): Array.of()
  4. arrayConcat(): Array.prototype.concat()
  5. arrayEvery(): Array.prototype.every()
  6. arrayFill(): Array.prototype.fill()
  7. arrayFilter(): Array.prototype.filter()
  8. arrayFind(): Array.prototype.find()
  9. arrayFindIndex(): Array.prototype.findIndex()
  10. arrayForEach(): Array.prototype.forEach(callback(currentValue , index, array), thisArg)
  11. arrayIncludes(): Array.prototype.includes()
  12. arrayIndexOf(): Array.prototype.indexOf()
  13. arrayJoin(): Array.prototype.join()
  14. arrayKeys(): Array.prototype.keys()
  15. arrayLastIndexOf: Array.prototype.lastIndexOf()
  16. arrayMap(): Array.prototype.map()
  17. arrayPop(): Array.prototype.pop()
  18. arrayPush(): Array.prototype.push()
  19. arrayReduce(): Array.prototype.reduce()
  20. arrayReduceRight(): Array.prototype.reduceRight()
  21. arrayReverse(): Array.prototype.reverse()
  22. arrayShift(): Array.prototype.shift()
  23. arraySlice(): Array.prototype.slice()
  24. arraySome(): Array.prototype.some()
  25. arraySort(): Array.prototype.sort()
  26. arraySplice(): Array.prototype.splice()
  27. arrayUnshift(): Array.prototype.unshift()
  28. arrayValues: Array.prototype.values()
  1. count(array, val = array[0]): 统计数组中值出现的次数
  2. countBy(array, fn): 根据函数统计数组中值出现的次数
  3. deepCopyArray: 深拷贝数组
  4. duplicate(array): 返回数组中的重复值
  5. filterFalsy(array): 过滤虚假值
  6. flatten(array, depth = 1): 展平数组到指定深度
  7. head(array, n = 1): 返回数组的前 n 个元素
  8. isArrayEvery(array, fn): 检测数组的所有元素是否都符合
  9. isArrayEveryEqual(array): 检测数组的所有元素是否相等
  10. isArrayNone(array, fn): 检测数组的所有元素是否都不符合
  11. isArraySome(array, fn): 检测数组的部分元素是否符合
  12. isArraySorted(array): 检测数组是否已排序。若为升序,返回 1;降序,返回-1;未排序,返回 0;
  13. offset(array, offset): 将指定数量的元素移动到数组的末尾。
  14. rest(array, n = 1): 返回数组的后 n 个元素
  15. reverse(array): 反转数组
  16. unique(array): 返回数组中的所有不同值。去重;

Boolean

  1. isFalse(boolean): 检测 false
  2. isTrue(boolean): 检测 true

Date

  1. date(...args): 创建 Date 对象
  2. day(date): 月份中的第几天
  3. dayOfWeek: 周中的第几天
  4. endofDay(date): 日期的最后一秒。23:59:59
  5. firstDayofMonth(date): 日期所在月的第一天
  6. format(date, fm): 格式化日期世界
  7. hour(date): 日期的小时
  8. lastDayofMonth(date): 日期所在月的最后一天
  9. lastNDay(date): 日期前 N 天
  10. millisecond(date): 日期的毫秒
  11. minute(date): 日期的分钟
  12. monday(date): 日期所在周的周一
  13. month(date): 日期的月份
  14. nextDays(date, n = 1): 指定日期后 N 天后
  15. nextHours(date, n = 1): 指定日期的 N 时后
  16. nextMinutes(date, n = 1): 指定日期的 N 分后
  17. nextMonths(date, n = 1): 指定日期的 N 月后
  18. nextSeconds(date, n = 1): 指定日期的 N 秒后
  19. nextWeeks(date, n = 1): 指定日期的 N 周后
  20. nextYears(date, n = 1): 指定日期的 N 年后
  21. range: 时间区段
  22. second(date): 日期的秒
  23. startofDay(date): 日期的第一秒。00:00:00
  24. sunday(date): 日期所在周的周日
  25. timeline(start, end): 返回起止时间中单位时间的连续时间数组
  26. timestamp(date): 时间戳
  27. tomorrow(date): 日期的后一天
  28. weekofYear(date): 日期所在年份的周次
  29. year(date): 日期的年份
  30. yesterday(date): 日期的前一天

DOM

  1. isBottomVisible(): 检测页面的底部是否可见
  2. isRoot(): 检测文档根节点
  3. isVisibleinViewport(el): 检测元素在视区中是否可见
  4. redirect(url): 重定向到指定 URL
  5. scrollPosition: 返回当前页的滚动位置
  6. scrollToTop(): 滚动至页面顶部
  7. url(): 返回当前 URL

Function

  • apply(thisArg, [argsArray]): Function.prototype.apply(thisArg, [argsArray])
  • bind(thisArg, ...args): Function.prototype.bind(thisArg, ...args)
  • call(thisArg, ...args): Function.prototype.call(thisArg, ...args)
  1. ajax(option): 异步 JavaScript 和 XML
  2. debounce(): 防抖:触发高频事件后 n 秒内函数只会执行一次,如果 n 秒内高频事件再次被触发,则重新计算时间
  3. forEach(object, callback): 从左向右遍历对象
  4. forEachRight(object, callback): 从右向左遍历对象
  5. forEachRightArray(object, callback): 从右向左遍历数组
  6. query(): 元素选择器
  7. queryAll(): 元素选择器
  8. swap(a, b): 交换两个元素的值
  9. throttle(): 节流:高频事件触发,但在 n 秒内只会执行一次,所以节流会稀释函数的执行频率
  10. timeTaken(fn, ...args): 测量执行函数所用的时间

Mobile

  1. mobileType(): 返回手机系统类型。Android,IOS;

Number

  1. areaofCircle(radius): 圆的面积
  2. avg(...nums): 平均值
  3. collatz(number): Collatz 算法
  4. digitize(num): 将数字转换为数字数组
  5. distance(x0, y0, x1, y1): 两点间的距离
  6. gcd(a, b): 计算两个数字之间最大的公共除数
  7. isDivisible(dividend, divisor): 检测第一个数值是否可被另一个数值整除
  8. isEven(number): 检测偶数
  9. isFinite(number): 检测无穷大
  10. isInteger(number): 检测整数
  11. isLeapYear(number): 检测闰年
  12. isNaN(number): 检测非数值
  13. isOdd(number): 检测奇数
  14. isSafeInteger(number): 检测安全整数
  15. LeapYears(startYear, endYear): 返回范围内的所有闰年
  16. max(...nums): 最大值
  17. min(...nums): 最小值
  18. PI(): 圆周率
  19. randomInteger(min, max = min + 1): 随机整数
  20. randomNumber(min, max = min + 1): 随机数值
  21. sum(...nums): 总值
  22. thousandsSeparator(num): 千位分隔符

Object

  1. extend(target, parent): 混合属性到目标对象
  2. isArray(obj): 检测对象是否为数组
  3. isBoolean(obj): 检测对象是否为布尔值
  4. isBrowser: 检测浏览器环境
  5. isDate(obj): 检测对象是否为日期时间
  6. isDefined(obj): 检测已定义
  7. isDOM(): 检测 DOM
  8. isEmpty(obj): 检测为空
  9. isFunction(obj): 检测函数
  10. isNull(obj): 检测 Null
  11. isNumber(obj): 检测数值
  12. isObject(obj): 检测对象
  13. isPrimitive(obj): 检测原始数据类型。字符串、数值、布尔值、Symbol。
  14. isRegExp(obj): 检测正则表达式
  15. isString(obj): 检测字符串
  16. isSymbol(obj): 检测 Symbol
  17. isUndefined(obj): 检测 Undefined
  18. stringify(json): JSON 转字符串
  19. typeOf(obj): 检测对象的数据类型

RegExp

  1. regs(): 常用正则表达式
  2. verifyEmail(): 验证邮箱
  3. verifyNumber(): 验证数值

String

  1. capitalize(): 将字符串的第一个字母大写
  2. capitalizeEveryWord(): 将字符串中每个单词的首字母大写
  3. hexToRgba(): hex 十六进制颜色转 rgb 颜色。
  4. isPalindrome(string): 检测回文字符串
  5. isStringOfArray(string): 检测字符串数组
  6. isStringOfBoolean(string): 检测字符串布尔值
  7. isStringOfNumber(string): 检测字符串数值
  8. isValidParenthess(): 检测是否是成对出现的括号。有效的括号;
  9. longestWord(text): 返回一段话中最长的单词
  10. nb(): NB
  11. randomString(length = 1, array = 0): 随机字符串
  12. rate(): 评分字符串星星
  13. removeDuplicates(string): 移除字符串中所有相邻重复项
  14. reverseString(string): 翻转字符串
  15. rgbToHex(): rgb 颜色转 hex 十六进制颜色。
  16. sb(): SB
  17. toJson(string): 字符串转 JSON
  18. [urlParams([url = window.location.href)](./packages/string/urlParams.js): 返回当前 URL 中的参数对象
  19. uuid(): 通用唯一识别码(Universally Unique Identifier)

参考

0.1.0

3 years ago

0.0.1

3 years ago