How to use array-map - 9 common examples

To help you get started, we’ve selected a few array-map examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Qiuyaxian / lm-ui / lm-angular / src / filters / name2value / name2value.ts View on Github external
export function name2value(name: any[], list: any[]): any {
  let rs = map(name, (one, index) => {
    let parent: any = ''
    if (index === 2) {
      // 可能存在区名一样的情况,比如南山区
      parent = find(list, item => {
        return item.name === name[1]
      }) || { value: '__' }

      if (specialMap[name[0]]) {
        parent = {
          value: specialMap[name[0]]
        }
      }
      return find(list, item => {
        return item.name === one && item.parent === parent.value
      })
    } else {
github shaungrady / angular-http-etag / src / httpDecorator.js View on Github external
function stringifyParams (obj) {
    return obj ? arrayMap(objectKeys(obj).sort(), function (key) {
      var val = obj[key]

      if (angular.isArray(val)) {
        return arrayMap(val.sort(), function (val2) {
          return encodeURIComponent(key) + '=' + encodeURIComponent(val2)
        }).join('&')
      }

      return encodeURIComponent(key) + '=' + encodeURIComponent(val)
    }).join('&') : ''
  }
github Qiuyaxian / lm-ui / lm-angular / src / components / popup-picker / filters.ts View on Github external
export function value2name (value: any, list: any, delimiter?: any): any {
  if (value && !list.length) {
    return ''
  }
  if (!delimiter) {
    delimiter = ' '
  }

  let rs = map(value, (one, index) => {
    if (list.length && Object.prototype.toString.call(list[0]) === '[object Array]') {
      return find(list[index], item => {
        return item.value === one
      })
    } else {
      return find(list, item => {
        return item.value === one
      })
    }
  })
  rs = rs.filter(one => {
    return typeof one !== 'undefined'
  })
  return map(rs, one => {
    return one.name
  }).join(delimiter).replace('--', '')
github Qiuyaxian / lm-ui / lm-angular / src / components / popup-picker / filters.ts View on Github external
return find(list, item => {
        return item.name === one && item.parent === parent.value
      })
    } else {
      if (index === 1 && specialMap[name[0]]) {
        return {
          value: specialMap[name[0]]
        }
      }
      return find(list, item => {
        return item.name === one
      })
    }
  })

  return map(rs, one => {
    return one ? one.value : '__'
  }).join(' ')
}
github shaungrady / angular-http-etag / src / httpDecorator.js View on Github external
return obj ? arrayMap(objectKeys(obj).sort(), function (key) {
      var val = obj[key]

      if (angular.isArray(val)) {
        return arrayMap(val.sort(), function (val2) {
          return encodeURIComponent(key) + '=' + encodeURIComponent(val2)
        }).join('&')
      }

      return encodeURIComponent(key) + '=' + encodeURIComponent(val)
    }).join('&') : ''
  }
github Qiuyaxian / lm-ui / lm-angular / src / filters / name2value / name2value.ts View on Github external
return find(list, item => {
        return item.name === one && item.parent === parent.value
      })
    } else {
      if (index === 1 && specialMap[name[0]]) {
        return {
          value: specialMap[name[0]]
        }
      }
      return find(list, item => {
        return item.name === one
      })
    }
  })

  return map(rs, one => {
    return one ? one.value : '__'
  }).join(' ')
}
github Qiuyaxian / lm-ui / lm-angular / src / filters / value2name / value2name.ts View on Github external
export function value2name (value: any, list?: any[], delimiter?: string): any {
  if (value && !list.length) {
    return ''
  }
  if (!delimiter) {
    delimiter = ' '
  }

  let rs = map(value, (one, index) => {
    if (list.length && Object.prototype.toString.call(list[0]) === '[object Array]') {
      return find(list[index], item => {
        return item.value === one
      })
    } else {
      return find(list, item => {
        return item.value === one
      })
    }
  })
  rs = rs.filter(one => {
    return typeof one !== 'undefined'
  })
  return map(rs, one => {
    return one.name
  }).join(delimiter).replace('--', '')
github Qiuyaxian / lm-ui / lm-angular / src / components / popup-picker / filters.ts View on Github external
let rs = map(value, (one, index) => {
    if (list.length && Object.prototype.toString.call(list[0]) === '[object Array]') {
      return find(list[index], item => {
        return item.value === one
      })
    } else {
      return find(list, item => {
        return item.value === one
      })
    }
  })
  rs = rs.filter(one => {
    return typeof one !== 'undefined'
  })
  return map(rs, one => {
    return one.name
  }).join(delimiter).replace('--', '')
}
github Qiuyaxian / lm-ui / lm-angular / src / filters / value2name / value2name.ts View on Github external
let rs = map(value, (one, index) => {
    if (list.length && Object.prototype.toString.call(list[0]) === '[object Array]') {
      return find(list[index], item => {
        return item.value === one
      })
    } else {
      return find(list, item => {
        return item.value === one
      })
    }
  })
  rs = rs.filter(one => {
    return typeof one !== 'undefined'
  })
  return map(rs, one => {
    return one.name
  }).join(delimiter).replace('--', '')
}

array-map

`[].map(f)` for older browsers

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis

Popular array-map functions