{"id":24518524,"url":"https://github.com/dperrymorrow/lil-p","last_synced_at":"2025-03-15T11:12:46.506Z","repository":{"id":4816394,"uuid":"5970101","full_name":"dperrymorrow/lil-p","owner":"dperrymorrow","description":"Javascript Prototype Extensions","archived":false,"fork":false,"pushed_at":"2014-06-24T04:06:07.000Z","size":241,"stargazers_count":1,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T01:42:49.294Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"RWOverdijk/AssetManager","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dperrymorrow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-09-26T18:16:39.000Z","updated_at":"2014-06-24T04:06:08.000Z","dependencies_parsed_at":"2022-08-20T23:31:14.753Z","dependency_job_id":null,"html_url":"https://github.com/dperrymorrow/lil-p","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/dperrymorrow%2Flil-p","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dperrymorrow%2Flil-p/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dperrymorrow%2Flil-p/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dperrymorrow%2Flil-p/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dperrymorrow","download_url":"https://codeload.github.com/dperrymorrow/lil-p/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243719398,"owners_count":20336607,"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":"2025-01-22T01:43:05.790Z","updated_at":"2025-03-15T11:12:46.476Z","avatar_url":"https://github.com/dperrymorrow.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"#lil-p (Javascript Prototype Extensions)\nAdd on functions to native ojects in Javascript. See the tests directory for examples of use. \nThe fastest way to get started is to include the [minified version](https://raw.github.com/dperrymorrow/lil-p/master/lib/lil_p.min.js).\n\n##String Object Extensions\n\n###truncate(charLimit:Number, ext:String);\nTruncates a string to the charLimit number, and then appends the ext if needed. Defaults to 10 and ... if params are ommited.\n\n````javascript\n'Hey there im a really long string'.truncate(5);\n// returns =\u003e 'Hey t...'\n\n'Hey there im a really long string'.truncate(5, '(shortened)');\n// returns =\u003e 'Hey t(shortened)'\n\n'Hey there im a really long string'.truncate();\n// returns =\u003e 'Hey there...'\n````\n\n###contains(substring:String);\nSearches the string for the substring, and returns true/false for if found.\n\n````javascript\n\"foobar\".contains('foo');\n// returns =\u003e true\n````\n\n###safe();\nStrips encodes HTMl characters in the string.\n\n````javascript\n\"foobar\u003ca href='foo'\u003ebar\u003c/a\u003e\".safe();\n// returns =\u003e \"foobar\u0026lt;a href='foo'\u0026gt;bar\u0026lt;/a\u0026gt;\"\n````\n\n###humanize();\nConverts camelcase, underscored, or dashed string to human readable space separated.\n\n````javascript\n'monkeyPants'.humanize();\n// returns =\u003e 'monkey pants'\n\n'monkey_Pants'.humanize();\n// returns =\u003e 'monkey pants'\n\n'monkey-Pants'.humanize(); \n// returns =\u003e 'monkey pants'\n````\n\n###inject(obj:Object);\nInject an object into a string just like in Ruby or Coffeescript #{} syntax\n\n````javascript\nvar obj = {victim: \"cat\"};\n\"dog bit #{victim}\".inject(obj);\n// returns =\u003e 'dogs bit cat'\n````\n\n###pluralize(amount:Number);\nConverts a string to plural if the number passed is greater than 1. If nothing passed, converts to plural.\n\n````javascript\n'dog'.pluralize(3);\n// returns =\u003e 'dogs'\n\n'dog'.pluralize(1);\n// returns =\u003e 'dog'\n````\n\n###singularize();\nConverts a plural string back to singular. No params.\n\n````javascript\n'dogs'.singularize();\n// returns =\u003e 'dog'\n````\n\n###wordWrap(chars:Number, breakChars:Array);\nTakes a string and inserts wbr HTML elements. This allows the browser to wrap within a word.\nDefaults to 25 and [\"/\", \"-\", \" \"]\n\n```javascript\n\"hello there-somethingerather\".wordWrap()\n// returns =\u003e \"hello \u003cwbr\u003ethere-\u003cwbr\u003esomethingerather\"\n\n\"123456789\".wordWrap(5);\n//returns =\u003e \"12345\u003cwbr\u003e6789\"\n````\n\n##Date Object Extensions\n\n###setTimeAgo(distance:String);\nTakes a date object and sets it back in time to human readable string such as \"2 weeks\", \"3 minutes\", \"5 years\", or \"30 seconds\"\n````javascript\nvar stamp = new Date(\"March 11, 1985 09:25:00 GMT-0800 (PST)\");\nstamp.setTimeAgo('6 weeks');\n// returns =\u003e 'Mon Jan 28 1985 09:25:00 GMT-0800 (PST)'\n````\n\n###distanceInWords(dateObject:Date, suffix:String);\nReturns a string of the distance in words from one Date object to another. Suffix defaults to \"ago\".\n\n````javascript\nvar start = new Date(\"March 11, 1985 09:25:00 GMT-0800 (PST)\");\nvar stop  = new Date(\"July 30, 1999 10:50:00 GMT-0800 (PST)\");\nstop.distanceInWords(start);\n// returns =\u003e '14 years, 5 months ago';\n````\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdperrymorrow%2Flil-p","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdperrymorrow%2Flil-p","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdperrymorrow%2Flil-p/lists"}