{"id":16048945,"url":"https://github.com/devongovett/slang","last_synced_at":"2025-04-05T22:06:01.459Z","repository":{"id":57362889,"uuid":"2055339","full_name":"devongovett/slang","owner":"devongovett","description":"A collection of utility functions for working with strings in JavaScript in the browser or Node","archived":false,"fork":false,"pushed_at":"2015-05-07T21:44:11.000Z","size":668,"stargazers_count":169,"open_issues_count":3,"forks_count":14,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T21:04:01.758Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devongovett.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-07-15T20:06:32.000Z","updated_at":"2024-11-14T20:38:32.000Z","dependencies_parsed_at":"2022-09-10T03:01:25.309Z","dependency_job_id":null,"html_url":"https://github.com/devongovett/slang","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2Fslang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2Fslang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2Fslang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2Fslang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devongovett","download_url":"https://codeload.github.com/devongovett/slang/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406087,"owners_count":20933803,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-09T00:11:32.894Z","updated_at":"2025-04-05T22:06:01.427Z","avatar_url":"https://github.com/devongovett.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Slang\n-----\nA collection of utility functions for working with strings in JavaScript in the browser or CommonJS.\n\n## Node Installation\n    npm install slang\n    \n## Annotated source code\nThe annotated source code for slang, generated by [Docco](http://jashkenas.github.com/docco/), \ncan be found [here](http://devongovett.github.com/slang/docs/slang.html).\n    \n## API\n\n### slang.isString\nReturns whether `input` is a string\n\n    slang.isString('testing'); // true\n    slang.isString(543);       // false\n    \n### slang.capitalize\nCapitalizes the first character of a string\n\n    slang.capitalize('hello world!'); // \"Hello world!\"\n    \n### slang.uncapitalize\nUncapitalizes the first character of a string\n\n    slang.uncapitalize('Hello world!); // \"hello world!\"\n    \n### slang.capitalizeWords\nCapitalizes each word in the string\n\n    slang.capitalizeWords('hello world!'); // \"Hello World!\"\n    \n### slang.uncapitalizeWords\nUncapitalizes each word in the string\n\n    slang.uncapitalizeWords('Hello World!'); // \"hello world!\"\n    \n### slang.isUpperCaseAt\nReturns whether the character at the provided character index is upper case.\n\n    slang.isUpperCaseAt('Testing', 0); // true\n    \n### slang.isLowerCaseAt\nReturns whether the character at the provided character index is lower case.\n\n    slang.isLowerCaseAt('Testing', 1); // true\n    \n### slang.swapcase\nInverts the case for each letter in the string\n\n    slang.swapcase('aaBBccDD'); // \"AAbbCCdd\"\n    \n### slang.camelize\nConverts a string of words seperated by dashes or spaces to camelCase\n\n    slang.camelize('hello world'); // \"helloWorld\"\n    slang.camelize('hello-world'); // \"helloWorld\"\n    \n### slang.uncamelize\n    slang.uncamelize('helloWorld'); // \"hello World\"\n    \n### slang.dasherize\nConverts a string of words or a camelCased string into a series of words separated by a dash (`-`)\n\n    slang.dasherize('this is dashed'); // \"this-is-dashed\"\n    \n### slang.repeat\nConcatenates the string `count` times\n\n    slang.repeat('Ho! ', 3); // \"Ho! Ho! Ho! \"\n    \n### slang.insert\nInserts `string` in `input` at `index`\n\n    slang.insert('this is cool!', 'really ', 8); // \"this is really cool!\"\n    \n### slang.remove\nRemoves the characters between the `start` and `end` indexes\n\n    slang.remove('this is really cool!', 8, 15); // \"this is cool!\"\n    \n### slang.chop\nRemoves the last character of `input`\n\n    slang.chop('hello'); // \"hell\"\n    \n### slang.trim\nRemoves leading and trailing whitespace from `input`.  Uses ES5's native trim is available.\n\n    slang.trim('hello '); // \"hello\"\n    \n### slang.trimLeft\nRemoves the leading whitespace from `input`\n\n    slang.trimLeft(' hello '); // \"hello \"\n    \n### slang.trimRight\nRemoves the trailing whitespace from `input`\n\n    slang.trimRight(' hello '); // \" hello\"\n    \n### slang.truncate\nTruncates `input` to `args.limit` or 10 and adds `args.omission` or \"...\"\n\n    slang.truncate('Lorem ipsum dolor sit amet.');                                           // 'Lorem ipsu...'\n    slang.truncate('Lorem ipsum dolor sit amet.', { limit: 5, omission: '...(read more)' }); // 'Lorem...(read more)'\n    \n### slang.join\nJoins an array into a humanized list.  The last element is joined by \"and\" by default, but you can change it.\n\n    slang.join(['red', 'blue', 'green']);       // \"red, blue and green\"\n    slang.join(['red', 'blue', 'green'], 'or'); // \"red, blue or green\"\n\n### slang.humanize\nReturns a humanized number with the correct suffix such as 1st, 2nd, 3rd or 4th.\n\n\tslang.humanize(2);\t // \"2nd\"\n\tslang.humanize(103); // \"103rd\"\n    \n### slang.contains\nReturns whether `input` contains `string`\n\n    slang.contains('hello world', 'world'); // true\n\n### slang.startsWith\nReturns whether `input` starts with `string`\n\n    slang.startsWith('hello world', 'hello'); // true\n    \n### slang.endsWith\nReturns whether `input` ends with `string`\n\n    slang.endsWith('hello world', 'world'); // true\n    \n### slang.isBlank\nReturns whether `input` is empty or only contains whitespace\n\n    slang.isBlank(' '); // true\n    slang.isBlank('');  // true\n    \n### slang.successor\nReturns the successor to str. The successor is calculated by incrementing characters starting \nfrom the rightmost alphanumeric (or the rightmost character if there are no alphanumerics) in the\nstring. Incrementing a digit always results in another digit, and incrementing a letter results in\nanother letter of the same case.\n\nIf the increment generates a carry, the character to the left of it is incremented. This \nprocess repeats until there is no carry, adding an additional character if necessary.\n\n    slang.successor(\"abcd\");      // \"abce\"\n    slang.successor(\"THX1138\");   // \"THX1139\"\n    slang.successor(\"\u003c\u003ckoala\u003e\u003e\"); // \"\u003c\u003ckoalb\u003e\u003e\"\n    slang.successor(\"1999zzz\");   // \"2000aaa\"\n    slang.successor(\"ZZZ9999\");   // \"AAAA0000\"\n\n### slang.guid\nReturns a unique guid of the specified length, or 32 by default\n\n    slang.guid();   // \"gE9FEtJknQVy3qkN9fxmTucYKTwFOno2\"\n    slang.guid(15); // \"b0apU4OH7ZgmEoU\"\n    \n### slang.addToPrototype\nAdds the methods from the slang object to String.prototype.  Does not add slang.guid, slang.humanize, slang.isString, slang.version, or itself.\n\n    slang.addToPrototype();\n    \"test\".capitalize(); // \"Test\"\n    \n### slang.lang\nThe default language to be used with all inflection methods. Initially set to 'en' for English.\n    \n### slang.pluralize\nPluralizes a string in the specified language or `slang.lang` by default\n\n    inflector.pluralize('man') // 'men'\n    inflector.pluralize('word', 'de') // non-default language\n    \n### slang.singularize\nSingularizes a string in the specified language or `slang.lang` by default\n\n    inflector.singularize('men') // 'man'\n    inflector.singularize('word', 'de') // non-default language\n    \n### slang.Language\nAn object that describes a language's inflection rules.  See source code for example usage.\n\n### slang.languages\nAn object holding `slang.Language` objects that describe various languages.  English ('en') is provided\nby default and you can add additional languages by adding them to `slang.languages`.  Then you can set\nthe default language to this new language by setting `slang.lang` or just use your language by passing\nthe language code as the second argument to `slang.pluralize` or `slang.singularize`.\n\n    // Create a language\n    var german = new slang.Language();\n    // Now add inflection rules\n    // ...\n\n    // Add language\n    slang.languages['de'] = german;\n\n    // Set default language\n    slang.lang = 'de';\n    \n## License\n\nslang is licensed under the MIT license.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevongovett%2Fslang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevongovett%2Fslang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevongovett%2Fslang/lists"}