Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 9 Examples of "decamelize-keys in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'decamelize-keys' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

function createDataset (input) {
  // Collect fields of interest.
  input = decamelizeKeys(input, '-')
  let data = {
    'id': input['id'],
    'source': input['source'],
    'source-address': input['source-address'],
    'name': input['name'] || '',
    'description': input['description'] || '',
    'access-key': input['access-key'] || ''
  }

  // Run post request as a promise.
  return new Promise((resolve, reject) => {
    this.axiosInstance.post('/datasets', data)
      .then(result => {
        let id = result.headers.location
        id = id.substr(id.lastIndexOf('/') + 1)
function createJob (input) {
  // Collect fields of interest.
  input = decamelizeKeys(input, '-')
  let data = {
    'dataset': input['dataset'],
    'objective': input['objective'],
    'alt-objectives': input['alt-objectives'] || [],
    'models': input['models'],
    'accept-new-models': input['accept-new-models'] === true,
    'max-tasks': Number(input['max-tasks']),
    'config-space': input['config-space'] || ''
  }

  // The config space must be passed as a string because that is how it is stored.
  if (typeof data['config-space'] !== 'string') {
    data['config-space'] = JSON.stringify(data['config-space'])
  }

  // Run post request as a promise.
function getTasks (query) {
  // This allows us to accept camel case keys.
  query = decamelizeKeys(query || {}, '-')

  // Run query and collect results as a promise.
  return new Promise((resolve, reject) => {
    common.runGetQuery(this.axiosInstance, '/tasks', query)
      .then(data => {
        let items = []

        if (data) {
          for (let i = 0; i < data.length; i++) {
            items.push(transformDataItem(data[i]))
          }
        }

        resolve(items)
      })
      .catch(e => {
function getDatasets (query) {
  // This allows us to accept camel case keys.
  query = decamelizeKeys(query || {}, '-')

  // Reformat schema fields.
  if ('schema-in' in query && typeof (query['schema-in']) !== 'string') {
    query['schema-in'] = JSON.stringify(query['schema-in'])
  }
  if ('schema-out' in query && typeof (query['schema-out']) !== 'string') {
    query['schema-out'] = JSON.stringify(query['schema-out'])
  }

  // Run query and collect results as a promise.
  return new Promise((resolve, reject) => {
    common.runGetQuery(this.axiosInstance, '/datasets', query)
      .then(data => {
        let items = []

        if (data) {
function validateModuleFields (input) {
  input = decamelizeKeys(input, '-')
  let errors = {}

  if (!input.id) {
    errors['id'] = 'The id must be specified.'
  } else if (!common.ID_FORMAT.test(input.id)) {
    errors['id'] = 'The id can contain only letters, numbers and underscores.'
  }

  if (!input.source) {
    errors['type'] = 'The type must be specified.'
  } else if (!['model', 'objective', 'optimizer'].includes(input.source)) {
    errors['source'] = 'The type must be either "model", "objective" or "optimizer".'
  }

  if (!input.source) {
    errors['source'] = 'The source must be specified.'
function validateJobFields (input) {
  input = decamelizeKeys(input, '-')
  let errors = {}

  if (!input.dataset) {
    errors['dataset'] = 'The dataset must be specified.'
  }

  if (!input.objective) {
    errors['objective'] = 'The objective must be specified.'
  }

  if (!input.models) {
    errors['models'] = 'The models list must be specified and cannot be empty.'
  }

  return errors
}
private async _get(
    target: string,
    options: PixivFetchOptions = {}
  ): Promise {
    options = options || {}

    if (options.data) {
      options.method = 'post'
      options.headers = {
        'Content-Type': 'application/x-www-form-urlencoded'
      }
      options.data = stringify(decamelizeKeys(options.data))
    }

    if (options.params) {
      options.params = decamelizeKeys(options.params)
    }
    const { data } = await instance(target, options as AxiosRequestConfig)
    this.nextUrl = data && data.next_url ? data.next_url : null
    return this.camelcaseKeys ? camelcaseKeys(data, { deep: true }) : data
  }
}
password: '',
      refreshToken: ''
    }

    if (this.refreshToken === '') {
      data.grantType = 'password'
      data.username = this.username
      data.password = this.password
    } else {
      data.grantType = 'refresh_token'
      data.refreshToken = this.refreshToken
    }

    const axiosResponse = await axios.post(
      'https://oauth.secure.pixiv.net/auth/token',
      stringify(decamelizeKeys(data)),
      { headers }
    )

    const { response } = axiosResponse.data
    this.auth = response
    this.refreshToken = axiosResponse.data.response.refresh_token
    instance.defaults.headers.common.Authorization = `Bearer ${response.access_token}`
    return this.camelcaseKeys
      ? camelcaseKeys(response, { deep: true })
      : response
  }
private async _get(
    target: string,
    options: PixivFetchOptions = {}
  ): Promise {
    options = options || {}

    if (options.data) {
      options.method = 'post'
      options.headers = {
        'Content-Type': 'application/x-www-form-urlencoded'
      }
      options.data = stringify(decamelizeKeys(options.data))
    }

    if (options.params) {
      options.params = decamelizeKeys(options.params)
    }
    const { data } = await instance(target, options as AxiosRequestConfig)
    this.nextUrl = data && data.next_url ? data.next_url : null
    return this.camelcaseKeys ? camelcaseKeys(data, { deep: true }) : data
  }
}

Is your System Free of Underlying Vulnerabilities?
Find Out Now