hrefjs-lite

    1.0.2 • Public • Published

    hrefjs-lite

    根据提供的href地址链接,解析出location结构数据, 参数与json互转

    安装

    npm i hrefjs-lite

    使用

    const hrefjs = require('hrefjs-lite')
    var location = hrefjs('https://www.cssjs.cn')
    
    // 返回结果
    { 
      hash: '',
      host: 'www.cssjs.cn',
      hostname: 'www.cssjs.cn',
      href: 'https://www.cssjs.cn',
      origin: '',
      pathname: '',
      port: '',
      protocol: 'https:',
      search: '',
      searchJson: {}
    }
    const hrefjs = require('hrefjs-lite')
    var json = {
        a: 10,
        b: 20
    }
    var param = hrefjs.json2param(json)
    // a=10&b=20
    
    param = 'a=10&b=20'
    json = hrefjs.param2json(param)   
    //{ a: '10', b: '20' }

    Install

    npm i hrefjs-lite

    DownloadsWeekly Downloads

    3

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    6.83 kB

    Total Files

    5

    Last publish

    Collaborators

    • avatar