Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Commit

Permalink
Version 1.0.44
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonardo Esparis committed Jan 25, 2016
1 parent 26e1d3a commit 267eaca
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Version 1.0.44.
---------------
- new function added, chr.

Version 1.0.43.
---------------
- new function added, ord.
Expand Down
31 changes: 30 additions & 1 deletion lib/_string/_lstring.js
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,11 @@ var rJust = function(_string, _times, _val) {
exports.rJust = rJust;


/**
* Returns the ASCII value of the first character of string.
* @param {string} _char A character
* @return {int} ASCII value
*/
var ord = function (_char) {

if(_char.length >= 2)
Expand All @@ -1108,4 +1113,28 @@ var ord = function (_char) {
return "";

}
exports.ord = ord;
exports.ord = ord;


/**
* return Return a specific character
*
* @param {integer}
* @return {string}
*/
var chr = function(integer){
if(!isDigit(integer)){
return "";
}

var _value = parseInt(integer);

for(var key in ASCII) {
if(ASCII[key] == _value){
return key;
}
}

return "";
}
exports.chr = chr;
5 changes: 5 additions & 0 deletions lib/extendStringProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var insert = string.insert;
var toCharArray = string.toCharArray;
var smartCount = string.smartCount;
var ord = string.ord;
var chr = string.chr;
var escape = html.escape;
var slugify = html.slugify;
var removeTag = html.removeTag;
Expand Down Expand Up @@ -200,6 +201,10 @@ module.exports = function() {
return ord(this);
}

String.prototype.chr = function(){
return chr(this);
}

String.prototype.removeTag = function() {
return removeTag(this);
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "l-string",
"version": "1.0.43",
"version": "1.0.44",
"description": "this is a module that you can use to manipulate strings ... ",
"main": "./l-string.js",
"directories": {
Expand Down
4 changes: 3 additions & 1 deletion tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

require('../l-string');


/*
console.log("leo".isUpper())
console.log("leo".isLower())
console.log("leo".isAlpha())
Expand All @@ -17,6 +17,7 @@ console.log("leo".multiply(2))
console.log("leo".rSlice(2, 4))
console.log("leo".dummyCount("e"))
console.log("0".ord())
console.log("36".chr())
console.log("leo".capitalize())
console.log("leo".getCharPosition("e"))
console.log("leo".reverse())
Expand Down Expand Up @@ -52,4 +53,5 @@ var b = a.addAttr2Tag("h13", "data-city", "algo")
var c = b.addStyle2Tag("h12", [['margin', '0 0 0 0'], ['color', 'red']])
var d = c.addClassName2Tag("h11", "leonardo")
console.log(d.addIdName2Tag("h12", "pepe").addAttr2Tag("h13", "data-city2", "algo2").addIdName2Tag("h12", "pep22e"))
*/

0 comments on commit 267eaca

Please sign in to comment.