Beta 7 with some repo names changed.

This commit is contained in:
Luis Fernando Molina committed 2020-11-15 13:05:19 +01:00
1 parent 0f7b40cca7
commit 963c19493a
3408 files changed
+462217 -15516

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
{
"name": "is-hex-prefixed",
"version": "1.0.0",
"description": "A simple method to check if a string is hex prefixed.",
"main": "src/index.js",
"scripts": {
"test": "mocha src/tests/**/**.js",
"test-travis": "node ./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha -- src/tests/**/*.js",
"coveralls": "npm run test-travis && cat ./coverage/lcov.info | coveralls"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/SilentCicero/is-hex-prefixed.git"
},
"engines": {
"npm": ">=3",
"node": ">=6.5.0"
},
"keywords": [
"is",
"hex",
"prefixed",
"prefix",
"checker",
"method"
],
"author": "Nick Dodson <thenickdodson@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/SilentCicero/is-hex-prefixed/issues"
},
"homepage": "https://github.com/SilentCicero/is-hex-prefixed#readme",
"devDependencies": {
"chai": "3.5.0",
"mocha": "3.2.0",
"istanbul": "0.4.5",
"coveralls": "2.11.9"
}
,"_resolved": "https://registry.npmjs.org/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz"
,"_integrity": "sha1-fY035q135dEnFIkTxXPggtd39VQ="
,"_from": "is-hex-prefixed@1.0.0"
}
+13
View File
@@ -0,0 +1,13 @@
/**
* Returns a `Boolean` on whether or not the a `String` starts with '0x'
* @param {String} str the string input value
* @return {Boolean} a boolean if it is or is not hex prefixed
* @throws if the str input is not a string
*/
module.exports = function isHexPrefixed(str) {
if (typeof str !== 'string') {
throw new Error("[is-hex-prefixed] value must be type 'string', is currently type " + (typeof str) + ", while checking isHexPrefixed.");
}
return str.slice(0, 2) === '0x';
}
+66
View File
@@ -0,0 +1,66 @@
const isHexPrefixed = require('../index.js');
const assert = require('chai').assert;
describe("isHexPrefixed", () => {
describe("constructor", () => {
it("should have the method exported", () => {
assert.equal(typeof isHexPrefixed, 'function');
});
});
describe("should function normall", () => {
it('should isHexPrefixed check if hex is prefixed', () => {
assert.equal(isHexPrefixed('0xsdffsd'), true);
assert.equal(isHexPrefixed('0x'), true);
assert.equal(isHexPrefixed('0x3982349284'), true);
assert.equal(isHexPrefixed('0x824723894jshdksjdhks'), true);
});
it('should isHexPrefixed check if hex is prefixed not prefixed', () => {
assert.equal(isHexPrefixed('sdffsd'), false);
assert.equal(isHexPrefixed(''), false);
assert.equal(isHexPrefixed('3982349284'), false);
assert.equal(isHexPrefixed('824723894jshdksjdhks'), false);
});
it('should isHexPrefixed throw as expected string got buffer', () => {
try {
isHexPrefixed(new Buffer());
} catch (error) {
assert.equal(typeof error, 'object');
}
});
it('should isHexPrefixed throw as expected string got empty object', () => {
try {
isHexPrefixed({});
} catch (error) {
assert.equal(typeof error, 'object');
}
});
it('should isHexPrefixed throw as expected string got number', () => {
try {
isHexPrefixed(823947243994);
} catch (error) {
assert.equal(typeof error, 'object');
}
});
it('should isHexPrefixed throw as expected string got undefined', () => {
try {
isHexPrefixed(undefined);
} catch (error) {
assert.equal(typeof error, 'object');
}
});
it('should isHexPrefixed throw as expected string got null', () => {
try {
isHexPrefixed(null);
} catch (error) {
assert.equal(typeof error, 'object');
}
});
});
});