How to use the inflection.singularize 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 dreamerslab / coke / lib / cli / generators / public.js View on Github external
dirs.push( 'app/controllers/' + namespace + '/' );
        dirs.push( 'app/views/' + namespace + '/' );
      }

      dirs.push( view_path );
      // start manipulation
      lib.init();
      // check if dir exists, if not creates it
      dirs.forEach( lib.create_dir );

      model = lib.valid_model_name( splited_controller );

      replace.init({
        capital   : model,
        plural    : splited_controller,
        singular  : inflection.singularize( splited_controller ),
        view_path : controller
      });

      var replace_rules = [
        replace.capital,
        replace.plural,
        replace.singular,
        replace.view_path
      ];

      generate_model( args, model, true );
      generate_view( args, controller, splited_controller, model, view_path, replace_rules );
      lib.create_file_by_template( controller_path, 'controllers/scaffold.js', replace_rules );
      generate_route( args, controller, has_namespace, true );
    });
  }
github pixelhandler / ember-jsonapi-resources / blueprints / jsonapi-initializer-test / index.js View on Github external
locals: function(options) {
    var resource = options.entity.name || options.args[1];

    return {
      friendlyTestName: testInfo.name(resource, "Unit", "Initializer"),
      dependencyDepth: getDependencyDepth(resource),
      entity: stringUtil.dasherize(inflector.singularize(resource)),
      resource: stringUtil.dasherize(inflector.pluralize(resource))
    };
  },
github cvent / lounge / lib / schema.utils.js View on Github external
const t = obj.type || obj.Type
      if ((t === String || t === Number) ||
        (t === 'string' || t === 'number') ||
        (Model.isPrototypeOf(t) && t.modelName) ||
        (obj.modelName && Model.isPrototypeOf(t)) ||
        (obj.modelName && t === Model)) {
        const path = getPathFromContext(ctx) || key

        let name = obj.indexName
        if (!name) {
          name = ctx.key || key
          const reg = new RegExp('^\\d+$')
          if (reg.test(name)) {
            name = ctx.path[ctx.path.length - 2]
          }
          name = inflection.singularize(name)
        }

        let indexType = obj.indexType ? obj.indexType.toLowerCase() : 'single'
        if (indexType !== 'single' && indexType !== 'array') {
          indexType = 'single'
        }

        const indexData = { path, name, indexType }
        if (obj.refKeyCase) {
          indexData.refKeyCase = obj.refKeyCase.toLowerCase()
        }

        inds.push(indexData)
      }
    }
  })
github jonschlinkert / normalize-keywords / index.js View on Github external
function properize(word, options) {
  options = _.extend({inflect: false}, options);
  if (!/\./.test(word)) {
    word = changeCase(word);
    if (options.inflect === false) {
      return word;
    }
    return inflection.singularize(word);
  }
  return word;
}
github eps1lon / poe-db / src / model / Model.js View on Github external
static name(dat_file) {
    return singularize(camelize(dat_file.replace(/\.dat$/, '')));
  }
github ember-admin / ember-cli-admin / blueprints / tree-view-resource / index.js View on Github external
locals: function(options){
    var modelName = inflection.camelize(inflection.singularize(options.entity.name), true);
    return {
      modelName: modelName
    };
  },
github denali-js / core / blueprints / resource / index.ts View on Github external
locals(argv: any) {
    let name = argv.name;
    name = pluralize(name);
    let plural = {
      name,
      camelCased: camelCase(name),
      className: upperFirst(camelCase(name)),
      dasherized: kebabCase(name),
      humanized: lowerCase(name)
    };
    name = singularize(name);
    let singular = {
      name,
      camelCased: camelCase(name),
      className: upperFirst(camelCase(name)),
      dasherized: kebabCase(name),
      humanized: lowerCase(name)
    };
    return { plural, singular };
  }
github seagull-js / seagull / src / scaffold / generators / code / exports_generator.ts View on Github external
function addNamed(gen: Base, file: string): void {
  const name = basename(file, extname(file))
  gen.addNamedDefaultExport(file, singularize(camelize(name)))
}
github pixelhandler / ember-jsonapi-resources / blueprints / jsonapi-initializer / index.js View on Github external
locals: function(options) {
    var resource = options.entity.name || options.args[1];
    var resourceSingular = inflector.singularize(resource);
    var resourcePlural = inflector.pluralize(resource);
    var relativePath = pathUtil.getRelativeParentPath(resource);

    var servicePath = relativePath + [ 'services', resourcePlural ].join('/');
    var modelPath = relativePath + [ 'models', resourceSingular ].join('/');
    var adapterPath = relativePath + [ 'adapters', resourceSingular ].join('/');
    var serializerPath = relativePath + [ 'serializers', resourceSingular ].join('/');

    if (options.pod) {
      servicePath = relativePath + [ resourceSingular, 'service' ].join('/');
      modelPath = relativePath + [ resourceSingular, 'model' ].join('/');
      adapterPath = relativePath + [ resourceSingular, 'adapter' ].join('/');
      serializerPath = relativePath + [ resourceSingular, 'serializer' ].join('/');
    }

    return {