How to use the inflection.camelize function in inflection

To help you get started, we’ve selected a few inflection 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 strongloop / loopback-datasource-juggler / lib / relation-definition.js View on Github external
if (typeof polymorphic == 'object') {
    selector = polymorphic.selector || polymorphic.as;
  }

  // relationName is eventually used as selector if provided and selector not already defined
  // it ultimately defaults to 'reference'
  selector = selector || relationName || 'reference';

  // make sure polymorphic is an object
  if (typeof polymorphic !== 'object') {
    polymorphic = {};
  }

  polymorphic.selector = selector;
  polymorphic.foreignKey = polymorphic.foreignKey || i8n.camelize(selector + '_id', true); // defaults to {{selector}}Id
  polymorphic.discriminator = polymorphic.discriminator || i8n.camelize(selector + '_type', true); // defaults to {{selectorName}}Type

  return polymorphic;
}
github mauriciogior / node-scaffold / lib / dissect-controller.js View on Github external
dissect : function(model)
		{
			this.nameSingular = inflection.singularize(model.name.toLowerCase());
			this.namePlural = inflection.pluralize(model.name.toLowerCase());
			this.nameSingularCap = inflection.camelize(this.nameSingular);
			this.namePluralCap = inflection.camelize(this.namePlural);

			this.fields = model.fields;

			var path = "./controllers/" + this.nameSingular + ".js";

			if(fs.existsSync(path) && !this.scaffold.config.overwrite)
			{
				this.scaffold.message('Controller \'' + this.nameSingular + '\' already exists! Use --force-overwrite or -F', ct.MSG_FAILED);
			}
			else
			{
				var buf;

				switch(this.scaffold.config.httpFramework)
				{
				case ct.HF_EXPRESS:
github marmelab / json-graphql-server / src / nameConverter.js View on Github external
export const getTypeFromKey = key => camelize(singularize(key));
github kaspernj / api_maker / npm-api-maker / src / devise.js View on Github external
static addUserScope(scope) {
    const currentMethodName = `current${inflection.camelize(scope)}`

    ApiMakerDevise[currentMethodName] = function() {
      return ApiMakerDevise.current().getCurrentScope(scope)
    }

    const isSignedInMethodName = `is${inflection.camelize(scope)}SignedIn`

    ApiMakerDevise[isSignedInMethodName] = function() {
      if (ApiMakerDevise.current().getCurrentScope(scope)) {
        return true
      }

      return false
    }
  }
github bojand / mailgun-js / lib / build.js View on Github external
function getName (name) {
  name = name.toLowerCase()
  name = inflection.dasherize(name).replace(/-/g, '_')
  name = inflection.camelize(name, true)

  return name
}
github marmelab / json-graphql-server / src / introspection / getSchemaFromData.js View on Github external
type: typesByName[type.name],
                args: {
                    id: { type: new GraphQLNonNull(GraphQLID) },
                },
            };
            fields[`all${camelize(pluralize(type.name))}`] = {
                type: new GraphQLList(typesByName[type.name]),
                args: {
                    page: { type: GraphQLInt },
                    perPage: { type: GraphQLInt },
                    sortField: { type: GraphQLString },
                    sortOrder: { type: GraphQLString },
                    filter: { type: filterTypesByName[type.name] },
                },
            };
            fields[`_all${camelize(pluralize(type.name))}Meta`] = {
                type: listMetadataType,
                args: {
                    page: { type: GraphQLInt },
                    perPage: { type: GraphQLInt },
                    filter: { type: filterTypesByName[type.name] },
                },
            };
            return fields;
        }, {}),
    });
github kaspernj / api_maker / npm-api-maker / src / devise.js View on Github external
static addUserScope(scope) {
    const currentMethodName = `current${inflection.camelize(scope)}`

    ApiMakerDevise[currentMethodName] = function() {
      return ApiMakerDevise.current().getCurrentScope(scope)
    }

    const isSignedInMethodName = `is${inflection.camelize(scope)}SignedIn`

    ApiMakerDevise[isSignedInMethodName] = function() {
      if (ApiMakerDevise.current().getCurrentScope(scope)) {
        return true
      }

      return false
    }
  }
github fortunejs / fortune-json-api / lib / index.js View on Github external
underscore(update[reservedKeys.type]),
            typeInflections[0]), recordTypes) :
          update[reservedKeys.type]

        if (!ids.some(matchId.bind(this, update)))
          throw new ConflictError('Invalid ID.')

        if (updateType !== type)
          throw new ConflictError('Incorrect type.')

        if (reservedKeys.attributes in update)
          for (let field in update[reservedKeys.attributes]) {
            const value = update[reservedKeys.attributes][field]

            if (inflectKeys)
              field = inflection.camelize(underscore(field), true)

            const fieldDefinition = fields[field] || {}
            const fieldType = fieldDefinition[keys.type]

            replace[field] = Array.isArray(value) ?
              value.map(cast(fieldType, options)) :
              castValue(value, fieldType, options)
          }

        if (reservedKeys.relationships in update)
          for (let field of Object.keys(update[reservedKeys.relationships])) {
            const value = update[reservedKeys.relationships][field]

            if (inflectKeys)
              field = inflection.camelize(underscore(field), true)