npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

rebuild-position-list

v0.1.0

Published

对地图点位数组数据进行重构。添加lonLat经纬度数组字段。并移除经纬度脏数据。防止地图渲染异常 ## Install ```` yarn add rebuild-position-list import changeLonLat from 'rebuild-position-list' const list1 = [ { lon: '1', lat: '2' }, { lon: '1.366346463', lat: '2.34234234223'

Downloads

3

Readme

rebuild-position-list

对地图点位数组数据进行重构。添加lonLat经纬度数组字段。并移除经纬度脏数据。防止地图渲染异常

Install

yarn add rebuild-position-list
import changeLonLat from 'rebuild-position-list'
const list1 = [
  {
    lon: '1', lat: '2'
  },
  {
    lon: '1.366346463', lat: '2.34234234223'
  },
  {
    lon: '1.366346463w', lat: '2.34234234223'
  }
]
changeLonLat(list1)
输出
[
  {
    "lon": "1",
    "lat": "2",
    "lonLat": [
      1,
      2
    ]
  },
  {
    "lon": "1.366346463",
    "lat": "2.34234234223",
    "lonLat": [
      1.366346463,
      2.34234234223
    ]
  }
]

Usage & TEST


import changeLonLat from '../../dist/index.umd'
import _ from 'lodash'
const list1 = [
  {
    lon: '1', lat: '2'
  },
  {
    lon: '1.366346463', lat: '2.34234234223'
  },
  {
    lon: '1.366346463w', lat: '2.34234234223'
  }
]
const list2 = [
  {
    lonLat: ['1', '8']
  },
  {
    lonLat: ['1.3663464635', '2.34234234223']
  },
  {
    lonLat: ['1.3663464635e', '2.34234234223']
  }
]
const list3 = [
  {
    longitude: 1, latitude: 2
  }
]
const list4 = [
  {
    lonLat: [1, 1]
  }
]
const list5 = [

]
const list6 = [
  {
    longitude: '1', latitude: '2'
  },
  {
    longitude: '1', latitude: '2'
  },
  {
    longitude: '1w', latitude: '2'
  }
]
const list7 = [
  {
    lon: 1, lat: 2
  }
]
// console.log(changeLonLat(list1));

expect.extend({
  toBeDivisibleBy (ary, keyName, ary2) {
    function checkIsHasLonLat () {
      if (ary.length === ary2.length === 0) return true

      if (ary.length === 0) {
        return false // 获得的数组长度为0
      }

      for (const item of ary) {
        if (!Object.prototype.hasOwnProperty.call(item, keyName)) return false // ary 中不存在 名为keyName的值时返回false
      }

      return true
    }
    const pass = checkIsHasLonLat()

    if (pass) {
      return {
        message: () => (
          `changeLonLat的方法检验数组 ${ary} 返回值存在 ${keyName}`
        ),
        pass: true
      }
    } else {
      return {
        message: () => (`changeLonLat的方法检验数组 ${ary} 返回值不存在 ${keyName}`),
        pass: false
      }
    }
  },

  toCheckListLength (ary, oldAry) {
    function checkListLength () {
      return ary.length === oldAry.length
    }

    const pass = checkListLength()
    if (pass) {
      return {
        message: () => (
          `changeLonLat的方法检验数组 ${oldAry} 中没有坏值,全部正确解析`
        ),
        pass: true
      }
    } else {
      return {
        message: () => (`changeLonLat的方法检验数组,返回值少了 ${oldAry.length - ary.length} 条数据`),
        pass: false
      }
    }
  },

  toCheckNewListIsNumber (ary, keyName) {
    /**
     * @return {boolean}
     */
    function CheckNewListIsNumber (ary, keyName) {
      if (ary.length === 0) return false // 获得的数组长度为0

      for (const item of ary) {
        if (typeof _.get(item, `[${keyName}][0]`) !== 'number' &&
          typeof _.get(item, `[${keyName}][1]`) !== 'number') return false
      }

      return true
    }
    const pass = CheckNewListIsNumber(ary, keyName)

    if (pass) {
      return {
        message: () => (
          'changeLonLat的方法检验数组lonLat字段是由数字组成的'
        ),
        pass: true
      }
    } else {
      return {
        message: () => ('changeLonLat的方法检验数组lonLat字段存在在至少一个不是由数字组成的'),
        pass: false
      }
    }
  },

  toResultIsNull (ary, oldAry) {
    function toCheckResultIsNull (ary, oldAry) {
      return ary.length === oldAry.length && ary.length === 0
    }
    const pass = toCheckResultIsNull(ary, oldAry)

    if (pass) {
      return {
        message: () => (
          '传入的changeLonLat的方法数组为空'
        ),
        pass: true
      }
    } else {
      return {
        message: () => ('传入的changeLonLat的方法数组为空或者传出的数组不为空'),
        pass: false
      }
    }
  }
})

const list = [list1, list2, list3, list4, list6, list7]

for (const item of list) {
  test('changeLonLat方法返回的数据有LonLat这个属性值', () => {
    expect(changeLonLat(item)).toBeDivisibleBy('lonLat', item)
  })

  test('changeLonLat方法返回的数据与旧数组的长度一致', () => {
    expect(changeLonLat(item)).toCheckListLength(item)
  })

  test('changeLonLat方法返回的数据的lonLat字段是否都是数字类型组成的数组', () => {
    expect(changeLonLat(item)).toCheckNewListIsNumber('lonLat')
  })
}

test('传入的参数空数组是否为空', () => {
  expect(changeLonLat(list5)).toResultIsNull(list5)
})