How to use the @ember/string.underscore function in @ember/string

To help you get started, we’ve selected a few @ember/string 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 DefinitelyTyped / DefinitelyTyped / types / ember__string / ember__string-tests.ts View on Github external
import { dasherize, camelize, capitalize, classify, decamelize, loc, underscore, w } from '@ember/string';

dasherize(); // $ExpectError
dasherize('blue man group'); // $ExpectType string
dasherize('', ''); // $ExpectError

camelize(); // $ExpectError
camelize('blue man group'); // $ExpectType string
camelize('', ''); // $ExpectError

decamelize(); // $ExpectError
decamelize('blue man group'); // $ExpectType string
decamelize('', ''); // $ExpectError

underscore(); // $ExpectError
underscore('blue man group'); // $ExpectType string
underscore('', ''); // $ExpectError

w(); // $ExpectError
w('blue man group'); // $ExpectType string[]
w('', ''); // $ExpectError

classify(); // $ExpectError
classify('blue man group'); // $ExpectType string
classify('', ''); // $ExpectError

capitalize(); // $ExpectError
capitalize('blue man group'); // $ExpectType string
capitalize('', ''); // $ExpectError

loc(); // $ExpectError
loc("_Hello World");  // $ExpectType string
github CenterForOpenScience / ember-osf-web / app / models / osf-model.ts View on Github external
async modifyM2MRelationship(
        this: T,
        action: 'post' | 'delete',
        relationshipName: RelationshipsFor & string,
        relatedModel: OsfModel,
    ) {
        const apiRelationshipName = underscore(relationshipName);
        const url = getSelfHref(this.relationshipLinks[apiRelationshipName]);

        const data = JSON.stringify({
            data: [{
                id: relatedModel.id,
                type: relatedModel.apiType,
            }],
        });

        if (!url) {
            throw new Error(`Couldn't find self link for ${apiRelationshipName} relationship`);
        }
        assert(`The related object is required to ${action} a relationship`, Boolean(relatedModel));

        const options: JQuery.AjaxSettings = {
            url,
github izelnakri / mber / ember-app-boilerplate / src / data / models / application / serializer.js View on Github external
keyForRelationship(key, typeClass, method) {
    if (method === 'serialize') {
      return underscore(key);
    }

    return `${underscore(key)}_id`;
  }
});
github travis-ci / travis-web / app / serializers / v3.js View on Github external
keyForAttribute(key) {
    return underscore(key);
  },
github discourse / discourse / app / assets / javascripts / discourse / models / store.js View on Github external
return ajax(url).then(result => {
      const typeName = underscore(this.pluralize(adapter.apiNameFor(type)));
      const content = result[typeName].map(obj =>
        this._hydrate(type, obj, result)
      );
      resultSet.set("content", content);
    });
  },
github CenterForOpenScience / ember-osf-web / mirage / views / osf-resource.ts View on Github external
export function osfToManyRelationship(
    server: Server,
    parentModelName: K,
    relationshipName: string & RelationshipsFor,
    options?: Partial,
) {
    const opts: RelationshipOptions = Object.assign({
        path: `/${pluralize(underscore(parentModelName))}/:parentID/relationships/${underscore(relationshipName)}`,
        relatedModelName: relationshipName,
        defaultSortKey: '-id',
    }, options);
    const mirageParentModelName = pluralize(camelize(parentModelName));
    const actions = gatherRelationshipActions(opts);

    if (actions.includes('related')) {
        const relationshipRelatedPath = opts.path.replace('relationships/', '');
        server.get(relationshipRelatedPath, function(schema, request) {
            const data = schema[mirageParentModelName]
                .find(request.params.parentID)[relationshipName]
                .models
                .filter((m: ModelInstance) => filter(m, request))
                .map((model: ModelInstance) => this.serialize(model).data);
            return process(schema, request, this, data, { defaultSortKey: opts.defaultSortKey });
        });
github getslash / backslash / webapp / app / adapters / application.js View on Github external
pathForType: function(type) {
    var plural = pluralize(type);
    return underscore(plural);
  },
github CenterForOpenScience / ember-osf-web / app / models / osf-model.ts View on Github external
get apiType() {
        return pluralize(underscore(this.modelName));
    }

@ember/string

A set of utilities to transform strings

MIT
Latest version published 5 months ago

Package Health Score

73 / 100
Full package analysis

Similar packages