2022年1月

Newtonsoft.Json转驼峰源码:

https://github.com/JamesNK/Newtonsoft.Json/issues/2187#issuecomment-538740046

前端

/**
 * 该源码来自Newtonsoft.Json原作者
 * https://github.com/JamesNK/Newtonsoft.Json/issues/2187#issuecomment-538740046
 */

/**
 * 字符串转驼峰命名
 * 此方法与Newtonsoft.Json转驼峰方式对应(其源码如下)
 * 参考:https://github.com/JamesNK/Newtonsoft.Json/blob/52190a3a3de6ef9a556583cbcb2381073e7197bc/Src/Newtonsoft.Json/Utilities/StringUtils.cs#L155
 * @param value 待转换的字符串
 */
export function toCamelCase(value: string): string {
  // nullish or empty or starting camel...
  if (value === null || value === undefined || value.length === 0 || !isUpperCase(value[0])) { return value }

  // convert
  const chars = Object.assign([] as string[], value)
  for (let i = 0; i < chars.length; i++) {
    // if the 2nd char is not upper, we finished conversion...
    if (i === 1 && !isUpperCase(chars[i])) { break }

    const hasNext = (i + 1 < chars.length)

    if (i > 0 && hasNext && !isUpperCase(chars[i + 1])) {
      // if the next character is a space, which is not considered uppercase
      // (otherwise we wouldn't be here...)
      // we want to ensure that the following:
      // 'FOO bar' is rewritten as 'foo bar', and not as 'foO bar'
      // The code was written in such a way that the first word in uppercase ends when if finds an uppercase letter followed by a lowercase letter.
      // Now a ' ' (space, (char)32) is considered not upper but in that case we still want our current character to become lowercase.
      if (isSeparator(chars[i + 1])) {
        chars[i] = chars[i].toLowerCase()
      }

      break
    }

    chars[i] = chars[i].toLowerCase()
  }

  return chars.join('')
}

function isUpperCase(value: string): boolean {
  return value === value.toUpperCase()
}

function isSeparator(value: string): boolean {
  // line separator/paragraph separator/space separators - https://www.compart.com/en/unicode/category
  const separator = '\u2028\u2029\u0020\u00a0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000'; return separator.indexOf(value) >= 0
}

export function camelizeDictionaryKeys(dictionary: Object): Object {
  const result = {}
  for (const key in dictionary) {
    const camelKey = key
      .split('.')
      .map(part => toCamelCase(part))
      .join('.')

    result[camelKey] = dictionary[key]
  }
  return result
}

源码引用自:

https://github.com/JamesNK/Newtonsoft.Json/issues/2187#issuecomment-538740046

交互:使用左上角的控件(或捏合)放大和缩小图像。单击(或触摸)并拖动光标以在图像中四处移动。

美国宇航局的好奇号火星车在 2019 年 11 月 24 日至 12 月 1 日期间捕捉到了迄今为​​止最高分辨率的火星表面全景图。没有火星车的版本包含近 18 亿像素;带有流动站的版本包含近 6.5 亿像素。这两个版本都由 1,000 多张图像组成,这些图像是在接下来的几个月中精心组装而成的。

火星车的桅杆相机,或称桅杆摄像机,使用其长焦镜头产生全景,并依靠其中角镜头产生包括火星车甲板和机械臂的低分辨率全景图。

圣地亚哥的 Malin Space Science Systems 建造并运营 Mastcam。美国宇航局喷气推进实验室是加州理工学院的一个部门,负责为该机构位于华盛顿的科学任务理事会管理火星科学实验室任务,并建造了好奇号火星车。

有关好奇号的更多信息,请访问:

https://mars.nasa.gov

https://www.nasa.gov/mission_pages/msl/index.html