Skip to content

Commit e6520c5

Browse files
author
Steve Thompson
committed
initial commit
0 parents  commit e6520c5

12 files changed

+277
-0
lines changed

.gitignore

Whitespace-only changes.

.idea/encodings.xml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/is-string-not-string.iml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+85
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.npmignore

Whitespace-only changes.

LICENSE

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
The MIT License
2+
3+
Copyright 2019 by Steve Thompson
4+
5+
6+
Permission is hereby granted, free of charge, to any person obtaining
7+
a copy of this software and associated documentation files (the
8+
"Software"), to deal in the Software without restriction, including
9+
without limitation the rights to use, copy, modify, merge, publish,
10+
distribute, sublicense, and/or sell copies of the Software, and to
11+
permit persons to whom the Software is furnished to do so, subject to
12+
the following conditions:
13+
14+
The above copyright notice and this permission notice shall be
15+
included in all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# isString(arg): boolean
2+
3+
Returns true if `arg` is of type 'string'.
4+
5+
# notString(arg): boolean
6+
7+
8+
## Installation
9+
`npm i @writetome51/is-string-not-string`
10+
11+
## Loading
12+
```
13+
// if using TypeScript:
14+
import { isString, notString } from '@writetome51/is-string-not-string';
15+
// if using ES5 JavaScript:
16+
var isString = require('@writetome51/is-string-not-string').isString
17+
var notString = require('@writetome51/is-string-not-string').notString;
18+
```

index.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
4+
5+
function isString(arg) {
6+
return (typeof arg === 'string');
7+
}
8+
exports.isString = isString;
9+
10+
11+
function notString(arg) {
12+
return !(isString(arg));
13+
}
14+
exports.notString = notString;

package.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "@writetome51/is-string-not-string",
3+
"version": "1.0.0",
4+
"description": "2 functions that check if argument is or is not string",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/writetome51/is-string-not-string.git"
12+
},
13+
"keywords": [
14+
"is",
15+
"not",
16+
"number",
17+
"integer",
18+
"float",
19+
"type-checking",
20+
"type",
21+
"check",
22+
"data-type"
23+
],
24+
"author": "Steve Thompson",
25+
"license": "MIT",
26+
"bugs": {
27+
"url": "https://github.com/writetome51/is-string-not-string/issues"
28+
},
29+
"homepage": "https://github.com/writetome51/is-string-not-string#readme",
30+
"dependencies": {
31+
}
32+
}

tests.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
var isString_notString_1 = require("./index");
4+
var strings = ['', ' ', ' ', '\n', '\r', '\\', '\'', '"', '`', '1', '0', '!@#$%^&*()'];
5+
var nonStrings = [true, 1, 0.0001, [8, 9], {}, function (i) { return (i === 2); }, false, { prop: 1 }, ['hello']];
6+
// Test 1: This must return true each time to pass:
7+
var results = [];
8+
for (var i = 0; i < strings.length; ++i) {
9+
results.push(isString_notString_1.isString(strings[i]));
10+
}
11+
if (results.length === strings.length && !(results.includes(undefined))
12+
&& !(results.includes(false)) && results.includes(true))
13+
console.log('test 1 passed');
14+
else
15+
console.log('test 1 FAILED');
16+
// Test 2: This must return false each time to pass:
17+
results = [];
18+
for (var i = 0; i < nonStrings.length; ++i) {
19+
results.push(isString_notString_1.isString(nonStrings[i]));
20+
}
21+
if (results.length === nonStrings.length && !(results.includes(undefined))
22+
&& !(results.includes(true)) && results.includes(false))
23+
console.log('test 2 passed');
24+
else
25+
console.log('test 2 FAILED');
26+
// Test 3: This must return true each time to pass:
27+
results = [];
28+
for (var i = 0; i < nonStrings.length; ++i) {
29+
results.push(isString_notString_1.notString(nonStrings[i]));
30+
}
31+
if (results.length === nonStrings.length && !(results.includes(undefined))
32+
&& !(results.includes(false)) && results.includes(true))
33+
console.log('test 3 passed');
34+
else
35+
console.log('test 3 FAILED');
36+
// Test 4: This must return false each time to pass:
37+
results = [];
38+
for (var i = 0; i < strings.length; ++i) {
39+
results.push(isString_notString_1.notString(strings[i]));
40+
}
41+
if (results.length === strings.length && !(results.includes(undefined))
42+
&& !(results.includes(true)) && results.includes(false))
43+
console.log('test 4 passed');
44+
else
45+
console.log('test 4 FAILED');

0 commit comments

Comments
 (0)