Comparing version
@@ -7,3 +7,3 @@ #!/usr/bin/env node | ||
var utils = require("../utils"); | ||
var ASCII = require("./ASCII").ASCII; | ||
var ASCII = require("./_ASCII").ASCII; | ||
@@ -1102,16 +1102,22 @@ var isNullOrUndefined = util.isNullOrUndefined; | ||
/** | ||
* Returns the ASCII value of the first character of string. | ||
* @param {string} _char A character | ||
* @return {int} ASCII value | ||
* Returns string's ASCII value of every element, if character is not | ||
* part of ascii, -1 will be the result. | ||
* | ||
* @param {string} string to scan | ||
* @return {int|array} ASCII values | ||
*/ | ||
var ord = function (_char) { | ||
if(_char.length >= 2) | ||
return ""; | ||
if(ASCII.hasOwnProperty(_char)) | ||
return ASCII[_char]; | ||
return ""; | ||
var ord = function (_s) { | ||
if(_s.length >= 0 && _s.length <= 1) { | ||
if(ASCII.hasOwnProperty(_s)) | ||
return ASCII[_s]; | ||
} else { | ||
var r = []; | ||
for (var i = 0; i < _s.length; i++) | ||
if(ASCII.hasOwnProperty(_s[i])) | ||
r.push(ASCII[_s[i]]); | ||
else | ||
r.push(-1); | ||
return r; | ||
} | ||
return -1; | ||
} | ||
@@ -1130,5 +1136,3 @@ exports.ord = ord; | ||
return ""; | ||
var _value = parseInt(integer); | ||
for(var key in ASCII) { | ||
@@ -1139,5 +1143,4 @@ if(ASCII[key] == _value){ | ||
} | ||
return ""; | ||
} | ||
exports.chr = chr; |
{ | ||
"name": "l-string", | ||
"version": "1.0.46", | ||
"version": "1.0.47", | ||
"description": "this is a module that you can use to manipulate strings ... ", | ||
@@ -5,0 +5,0 @@ "main": "./l-string.js", |
@@ -6,3 +6,2 @@ **l-string** :thumbsup: :trollface: [](https://travis-ci.org/leoxnidas/l-string) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=BQKLKSBKH4DPE) | ||
Install | ||
@@ -16,6 +15,4 @@ ------- | ||
```javascript | ||
require("l-string"); | ||
console.log("a".ord()) | ||
@@ -50,3 +47,2 @@ console.log("<h1>\"\'<>&leonardo</h1>".escape()) | ||
Usage, client Side. | ||
@@ -95,3 +91,3 @@ ------------------ | ||
Copyright (C) 2015-2016 Leonardo Esparis <leo.leo.leoxnidas.c.14@gmail.com>. | ||
Copyright (C) 2015-2017 Leonardo Esparis <leo.leo.leoxnidas.c.14@gmail.com>. | ||
@@ -116,2 +112,8 @@ Permission is hereby granted, free of charge, to any person obtaining a copy | ||
Version 1.0.47. | ||
--------------- | ||
- test.js file updated. | ||
- ord function now shall Returns string's ASCII value of every element | ||
- changin ASCII.js to _ASCII.js filename | ||
Version 1.0.46. | ||
@@ -118,0 +120,0 @@ --------------- |
@@ -18,3 +18,4 @@ #!/usr/bin/env node | ||
console.log("leo".dummyCount("e")) | ||
console.log("0".ord()) | ||
console.log("acb!@#$%^&*()_+".ord()) | ||
console.log("+".ord()) | ||
console.log("95".chr()) | ||
@@ -55,3 +56,1 @@ console.log("leo".capitalize()) | ||
console.log(d.addIdName2Tag("h12", "pepe").addAttr2Tag("h13", "data-city2", "algo2").addIdName2Tag("h12", "pep22e")) | ||
Sorry, the diff of this file is not supported yet
58794
0.71%1749
0.63%237
0.85%