Initial commit

This commit is contained in:
2024-11-03 17:41:45 +01:00
commit c1640c1754
8043 changed files with 775536 additions and 0 deletions

12
node_modules/is-json/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,12 @@
.*.swp
._*
.DS_Store
.git
.hg
.lock-wscript
.svn
.wafpickle-*
CVS
npm-debug.log
*.sublime-project
*.sublime-workspace

14
node_modules/is-json/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,14 @@
language: node_js
node_js:
- "0.12"
- "0.10"
- "0.8"
branches:
only:
- master
notifications:
email:
- joaquim.serafim@gmail.com
script: npm test
before_install:
- npm install -g npm@~1.4.6

15
node_modules/is-json/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,15 @@
The ISC License
Copyright (c) Joaquim José F. Serafim
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

41
node_modules/is-json/README.md generated vendored Normal file
View File

@@ -0,0 +1,41 @@
# is-json
<a href="https://nodei.co/npm/is-json/"><img src="https://nodei.co/npm/is-json.png?downloads=true"></a>
[![Build Status](https://travis-ci.org/joaquimserafim/is-json.png?branch=master)](https://travis-ci.org/joaquimserafim/is-json)
check if a string is a valid JSON string without using Try/Catch and is a JSON object
**V1.2**
isJSON(str*, [passObjects=bool])
*with `passObjects = true` can pass a JSON object in `str`, default to `false`
var isJSON = require('is-json');
var good_json = '{"a":"obja","b":[0,1,2],"c":{"d":"some object"}}';
var bad_json = '{"a":"obja""b":[0,1,2],"c":{"d":"some object"}}';
var str_number = '121212';
console.log(isJSON(good_json)); // true
console.log(isJSON(bad_json)); // false
console.log(isJSON(str_number)); // false
// check is an object
var object = {a: 12, b: [1,2,3]};
console.log(isJSON(object, true)); // true
// can use isJSON.strict (uses try/catch) if wants something more robust
console.log(isJSON.strict('{\n "config": 123,\n "test": "abcde" \n}')); // true

48
node_modules/is-json/index.js generated vendored Normal file
View File

@@ -0,0 +1,48 @@
'use strict'
module.exports = isJSON;
isJSON.strict = strict;
function isJSON (str, pass_object) {
if (pass_object && isObject(str)) return true;
if (!isString(str)) return false;
str = str.replace(/\s/g, '').replace(/\n|\r/, '');
if (/^\{(.*?)\}$/.test(str))
return /"(.*?)":(.*?)/g.test(str);
if (/^\[(.*?)\]$/.test(str)) {
return str.replace(/^\[/, '')
.replace(/\]$/, '')
.replace(/},{/g, '}\n{')
.split(/\n/)
.map(function (s) { return isJSON(s); })
.reduce(function (prev, curr) { return !!curr; });
}
return false;
}
function strict (str) {
if (isObject(str)) {
return true;
}
try {
return JSON.parse(str) && true;
} catch (ex) {
return false;
}
}
function isString (x) {
return Object.prototype.toString.call(x) === '[object String]';
}
function isObject (obj) {
return Object.prototype.toString.call(obj) === '[object Object]';
}

29
node_modules/is-json/package.json generated vendored Normal file
View File

@@ -0,0 +1,29 @@
{
"name": "is-json",
"version": "2.0.1",
"description": "check if a string is a valid JSON string without using Try/Catch",
"main": "index.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "node test"
},
"repository": {
"type": "git",
"url": "git@github.com:joaquimserafim/is-json.git"
},
"keywords": [
"JSON",
"validation"
],
"author": "@joaquimserafim",
"license": "ISC",
"bugs": {
"url": "https://github.com/joaquimserafim/is-json/issues"
},
"homepage": "https://github.com/joaquimserafim/is-json",
"devDependencies": {
"tape": "^2.13.1"
}
}

33
node_modules/is-json/test/index.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
var test = require('tape');
var isJSON = require('../');
test('performe isJSON verifications', function (assert) {
assert.deepEqual(isJSON('asdada[]asdadada sd asdasda das das'), false, '`asdada[]asdadada sd asdasda das das`, should return false');
assert.deepEqual(isJSON(null), false, '`null`, should return false');
assert.deepEqual(isJSON(false), false, '`false`, should return false');
assert.deepEqual(isJSON(''), false, '`\'\'`, should return false');
assert.deepEqual(isJSON('normal string'), false, '\'normal string\', should return false');
assert.deepEqual(isJSON(2014), false, '`2014`, should return false');
assert.deepEqual(isJSON(2014.5), false, '`2014.5`, should return false');
assert.deepEqual(isJSON([1,2,3,4]), false, '`[1,2,3,4]`, should return false');
assert.deepEqual(isJSON({a: 12, b: [1,2,3]}), false, 'a JSON object `{a: 12, b: [1,2,3]},`, should return false');
assert.deepEqual(isJSON({a: 12, b: [1,2,3]}, true), true,
'a JSON object `{a: 12, b: [1,2,3]}` but pass the 2 arg as true (check objects too), should return true');
assert.deepEqual(isJSON('{"a":"obja","b":[0,1,2],"c":{"d":"some object"}}'), true,
'`{"a":"obja","b":[0,1,2],"c":{"d":"some object"}}`, should return true');
assert.deepEqual(isJSON('1,2,3'), false, '`1,2,3`, should return false');
assert.deepEqual(isJSON('{1,2,3}'), false, '`{1,2,3}`, should return false');
assert.deepEqual(isJSON('[{"a": 123}, {1,2,3}}]'), false, '`[{"a": 123, {1,2,3}}]`, should return false');
var cobj = '[{"a": {"aa": [1,2,3,4], "aaa": {"d": 1212}}}, {"b": "test", "c": [1,2,3], "date": "' + new Date() + '"}]';
assert.deepEqual(isJSON(cobj), true, cobj + ', should return true');
assert.deepEqual(isJSON(new Date()), false, '`Date`, should return false');
assert.deepEqual(isJSON.strict('{\n "config": 123,\n "test": "abcde" \n}'), true, '`{\n "config": 123,\n "test": "abcde" \n}`, should return true');
assert.deepEqual(
isJSON.strict({a: 1}),
true,
'should return true when passing a js object into `strict`'
);
assert.end();
});