How to use humps - 10 common examples

To help you get started, we’ve selected a few humps 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 NorikDavtian / semantic-dashboard / src / api / inbox.js View on Github external
export const getEmails = async (pageNo = 1) => {
  const response = await fetch(`${baseUrl}/api/inbox?page=${pageNo}`, {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json'
    }
  });

  if (response.status === 200) {
    const body = await response.json();
    // console.log('response: ', body);
    const res = camelizeKeys(body)
    console.log('RES: ', res);

    return camelizeKeys(body);
  }
  throw new Error('Can not fetch emails');
};
github ello / webapp / src / sagas / requester.js View on Github external
try {
    response = yield call(sagaFetch, endpointPath, options)
  } catch (error) {
    updateRunningFetches(error.response)
    yield fork(handleRequestError, error, action)
    return false
  }

  const { json, serverResponse } = response

  updateRunningFetches(serverResponse)

  payload.serverStatus = serverResponse.status
  if (serverResponse.status === 200 || serverResponse.status === 201) {
    payload.response = camelizeKeys(json)
    const linkPagination = parseLink(serverResponse.headers.get('Link'))
    // for now these need to remain parseInt instead of Number cast
    // due to StreamContainer casting them as number and checking for 0
    // when you do Number(null) it equals 0, thanks javascript!
    linkPagination.totalCount = parseInt(serverResponse.headers.get('X-TotalCount'), 10)
    linkPagination.totalPages = parseInt(serverResponse.headers.get('X-Total-Pages'), 10)
    linkPagination.totalPagesRemaining = parseInt(serverResponse.headers.get('X-Total-Pages-Remaining'), 10)
    payload.pagination = linkPagination
  }
  yield put({ meta, payload, type: SUCCESS })
  yield call(fireSuccessAction)
  return true
}
github codesandbox / codesandbox-client / packages / app / src / app / store / services / api.js View on Github external
// If it is an absolute url.
  const url = getUrl(endpoint);

  const options = { url, method };

  if (jwt) {
    options.headers = {
      Authorization: `Bearer ${jwt}`,
    };
  }

  if (body) {
    if (method === 'GET' && body != null) {
      // Convert body to ?x=y&b=a format
      options.url += optionsToParameterizedUrl(decamelizeKeys(body));
    } else {
      options.data = decamelizeKeys(body);
    }
  }

  const result = await axios(options);

  const camelizedData = shouldCamelize
    ? camelizeKeys(result.data)
    : result.data;

  // Quickfix to prevent underscored dependencies from being camelized.
  // Never store data as keys in the future.
  if (
    camelizedData &&
    camelizedData.data &&
github codesandbox / codesandbox-client / src / app / store / services / api.js View on Github external
const url = getUrl(endpoint);

  const options = { url, method };

  if (jwt) {
    options.headers = {
      Authorization: `Bearer ${jwt}`,
    };
  }

  if (body) {
    if (method === 'GET' && body != null) {
      // Convert body to ?x=y&b=a format
      options.url += optionsToParameterizedUrl(decamelizeKeys(body));
    } else {
      options.data = decamelizeKeys(body);
    }
  }

  const result = await axios(options);
  return shouldCamelize ? camelizeKeys(result.data) : result.data;
});
github sysgears / apollo-universal-starter-kit / modules / user / server-ts / sql.js View on Github external
.leftJoin('user_profile AS up', 'up.user_id', 'u.id')
      .leftJoin('auth_certificate AS ca', 'ca.user_id', 'u.id')
      .leftJoin('auth_facebook AS fa', 'fa.user_id', 'u.id')
      .leftJoin('auth_google AS ga', 'ga.user_id', 'u.id')
      .leftJoin('auth_github AS gha', 'gha.user_id', 'u.id')
      .leftJoin('auth_linkedin AS lna', 'lna.user_id', 'u.id');

    // add order by
    if (orderBy && orderBy.column) {
      let column = orderBy.column;
      let order = 'asc';
      if (orderBy.order) {
        order = orderBy.order;
      }

      queryBuilder.orderBy(decamelize(column), order);
    }

    // add filter conditions
    if (filter) {
      if (has(filter, 'role') && filter.role !== '') {
        queryBuilder.where(function() {
          this.where('u.role', filter.role);
        });
      }

      if (has(filter, 'isActive') && filter.isActive !== null) {
        queryBuilder.where(function() {
          this.where('u.is_active', filter.isActive);
        });
      }
github sysgears / domain-schema / packages / knex / src / index.ts View on Github external
public selectBy = (schema: typeof Schema, fields: string[]) => {
    const domainSchema = new DomainSchema(schema);
    // form table name
    const tableName = decamelize(domainSchema.__.name);

    // select fields
    const parentPath = [];
    const selectItems = [];
    const joinNames = [];
    this._getSelectFields(fields, parentPath, domainSchema, selectItems, joinNames, []);

    debug('Select items:', selectItems);
    debug('Join on tables:', joinNames);

    return query => {
      // join table names
      joinNames.map(joinName => {
        query.leftJoin(joinName, `${joinName}.${tableName}_id`, `${tableName}.id`);
      });
github Phyks / ampache_react / app / actions / APIActions.js View on Github external
include
            );
            // Set success callback
            fetchAction.payload.dispatch[1] = (
                jsonData => dispatch => {
                    dispatch(fetchItemSuccess(jsonData));
                }
            );
            // Dispatch action
            dispatch(fetchAction);
        };
    };

    // Remap the above methods to methods including item name
    var returned = {};
    const camelizedAction = humps.pascalize(action);
    returned["loadPaginated" + camelizedAction] = loadPaginatedItems;
    returned["load" + camelizedAction.rstrip("s")] = loadItem;
    return returned;
}
github DefinitelyTyped / DefinitelyTyped / humps / humps-tests.ts View on Github external
humps.camelizeKeys(someObject, function (key, convert) {
  return /^[A-Z0-9_]+$/.test(key) ? key : convert(key);
});

humps.decamelizeKeys(someObject, function (key, convert, options) {
  return /^[A-Z0-9_]+$/.test(key) ? key : convert(key, options);
});


humps.camelize('hello_world-foo bar');

humps.pascalize('hello_world-foo bar');

humps.decamelize('helloWorldFooBar');
humps.decamelize('helloWorldFooBar', someOptions);
humps.decamelize('helloWorld1', { split: /(?=[A-Z0-9])/ })

humps.depascalize('helloWorldFooBar');

humps.camelizeKeys(someObject);
humps.pascalizeKeys(someObject);
humps.decamelizeKeys(someObject);
humps.depascalizeKeys(someObject);

humps.camelizeKeys(someObject, someOptions);
humps.pascalizeKeys(someObject, someOptions);
humps.decamelizeKeys(someObject, someOptions);
humps.depascalizeKeys(someObject, someOptions);

humps.camelizeKeys(someObject, someOptions2);
humps.pascalizeKeys(someObject, someOptions2);
github DefinitelyTyped / DefinitelyTyped / humps / humps-tests.ts View on Github external
humps.camelizeKeys(someObject, function (key, convert) {
  return /^[A-Z0-9_]+$/.test(key) ? key : convert(key);
});

humps.decamelizeKeys(someObject, function (key, convert, options) {
  return /^[A-Z0-9_]+$/.test(key) ? key : convert(key, options);
});


humps.camelize('hello_world-foo bar');

humps.pascalize('hello_world-foo bar');

humps.decamelize('helloWorldFooBar');
humps.decamelize('helloWorldFooBar', someOptions);
humps.decamelize('helloWorld1', { split: /(?=[A-Z0-9])/ })

humps.depascalize('helloWorldFooBar');

humps.camelizeKeys(someObject);
humps.pascalizeKeys(someObject);
humps.decamelizeKeys(someObject);
humps.depascalizeKeys(someObject);

humps.camelizeKeys(someObject, someOptions);
humps.pascalizeKeys(someObject, someOptions);
humps.decamelizeKeys(someObject, someOptions);
humps.depascalizeKeys(someObject, someOptions);

humps.camelizeKeys(someObject, someOptions2);
humps.pascalizeKeys(someObject, someOptions2);
humps.decamelizeKeys(someObject, someOptions2);
github DefinitelyTyped / DefinitelyTyped / humps / humps-tests.ts View on Github external
humps.camelizeKeys(someObject);

humps.camelizeKeys(someArray);

humps.camelizeKeys(someObject, function (key, convert) {
  return /^[A-Z0-9_]+$/.test(key) ? key : convert(key);
});

humps.decamelizeKeys(someObject, function (key, convert, options) {
  return /^[A-Z0-9_]+$/.test(key) ? key : convert(key, options);
});


humps.camelize('hello_world-foo bar');

humps.pascalize('hello_world-foo bar');

humps.decamelize('helloWorldFooBar');
humps.decamelize('helloWorldFooBar', someOptions);
humps.decamelize('helloWorld1', { split: /(?=[A-Z0-9])/ })

humps.depascalize('helloWorldFooBar');

humps.camelizeKeys(someObject);
humps.pascalizeKeys(someObject);
humps.decamelizeKeys(someObject);
humps.depascalizeKeys(someObject);

humps.camelizeKeys(someObject, someOptions);
humps.pascalizeKeys(someObject, someOptions);
humps.decamelizeKeys(someObject, someOptions);
humps.depascalizeKeys(someObject, someOptions);

humps

Underscore-to-camelCase converter (and vice versa) for strings and object keys in JavaScript.

MIT
Latest version published 7 years ago

Package Health Score

53 / 100
Full package analysis