Finish admin dashboard and update sql
This commit is contained in:
47
controllers/category.js
Normal file
47
controllers/category.js
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
const db = require("../utils/database");
|
||||||
|
|
||||||
|
exports.getAllCategoriesWithPagination = async (req, res) => {
|
||||||
|
const limit = +req.query?.limit;
|
||||||
|
const page = +req.query?.page;
|
||||||
|
const offset = (page - 1) * limit;
|
||||||
|
try {
|
||||||
|
const [data, _] = await db.execute(
|
||||||
|
"SELECT * FROM Category C ORDER BY C.CategoryID ASC LIMIT ? OFFSET ?",
|
||||||
|
[limit.toString(), offset.toString()]
|
||||||
|
);
|
||||||
|
|
||||||
|
const [result] = await db.execute("SELECT COUNT(*) AS count FROM Category");
|
||||||
|
const { count: total } = result[0];
|
||||||
|
return res.json({ data, total });
|
||||||
|
} catch (error) {
|
||||||
|
res.json({ error: "Cannot fetch categories from database!" });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.addCategory = async (req, res) => {
|
||||||
|
const { name } = req.body;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const [result] = await db.execute(
|
||||||
|
"INSERT INTO Category (Name) VALUES (?)",
|
||||||
|
[name]
|
||||||
|
);
|
||||||
|
res.json({ message: "Adding new category successfully!" });
|
||||||
|
} catch (error) {
|
||||||
|
res.json({ error: "Cannot add new category!" });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.removeCategory = async (req, res) => {
|
||||||
|
const { id } = req.params;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const [result] = await db.execute(
|
||||||
|
`DELETE FROM Category WHERE CategoryID = ?`,
|
||||||
|
[id]
|
||||||
|
);
|
||||||
|
res.json({ message: "Delete category successfully!" });
|
||||||
|
} catch (error) {
|
||||||
|
res.json({ error: "Cannot remove category from database!" });
|
||||||
|
}
|
||||||
|
};
|
||||||
90
controllers/history.js
Normal file
90
controllers/history.js
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
const db = require("../utils/database");
|
||||||
|
|
||||||
|
exports.HistoryByUserId = async (req, res) => {
|
||||||
|
const { id } = req.body;
|
||||||
|
try {
|
||||||
|
const [data] = await db.execute(
|
||||||
|
`
|
||||||
|
WITH RankedImages AS (
|
||||||
|
SELECT
|
||||||
|
P.ProductID,
|
||||||
|
P.Name AS ProductName,
|
||||||
|
P.Price,
|
||||||
|
P.Date AS DateUploaded,
|
||||||
|
U.Name AS SellerName,
|
||||||
|
I.URL AS ProductImage,
|
||||||
|
C.Name AS Category,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY P.ProductID ORDER BY I.URL) AS RowNum
|
||||||
|
FROM Product P
|
||||||
|
JOIN Image_URL I ON P.ProductID = I.ProductID
|
||||||
|
JOIN User U ON P.UserID = U.UserID
|
||||||
|
JOIN Category C ON P.CategoryID = C.CategoryID
|
||||||
|
JOIN History H ON H.ProductID = P.ProductID
|
||||||
|
WHERE H.UserID = ?
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
ProductID,
|
||||||
|
ProductName,
|
||||||
|
Price,
|
||||||
|
DateUploaded,
|
||||||
|
SellerName,
|
||||||
|
ProductImage,
|
||||||
|
Category
|
||||||
|
FROM RankedImages
|
||||||
|
WHERE RowNum = 1;
|
||||||
|
`,
|
||||||
|
[id],
|
||||||
|
);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
message: "Products fetched successfully",
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error finding products:", error);
|
||||||
|
return res.status(500).json({
|
||||||
|
found: false,
|
||||||
|
error: "Database error occurred",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.AddHistory = async (req, res) => {
|
||||||
|
const { userID, productID } = req.body;
|
||||||
|
console.log(userID);
|
||||||
|
try {
|
||||||
|
// Use parameterized query to prevent SQL injection
|
||||||
|
const [result] = await db.execute(
|
||||||
|
`INSERT INTO History (UserID, ProductID) VALUES (?, ?)`,
|
||||||
|
[userID, productID],
|
||||||
|
);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
message: "Product added to history successfully",
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error adding favorite product:", error);
|
||||||
|
return res.json({ error: "Could not add favorite product" });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.DelHistory = async (req, res) => {
|
||||||
|
const { userID, productID } = req.body;
|
||||||
|
console.log(userID);
|
||||||
|
try {
|
||||||
|
// Use parameterized query to prevent SQL injection
|
||||||
|
const [result] = await db.execute(`DELETE FROM History WHERE UserID=?`, [
|
||||||
|
userID,
|
||||||
|
]);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
message: "Product deleted from History successfully",
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error adding favorite product:", error);
|
||||||
|
return res.json({ error: "Could not add favorite product" });
|
||||||
|
}
|
||||||
|
};
|
||||||
301
controllers/product.js
Normal file
301
controllers/product.js
Normal file
@@ -0,0 +1,301 @@
|
|||||||
|
const db = require("../utils/database");
|
||||||
|
|
||||||
|
exports.addProduct = async (req, res) => {
|
||||||
|
const { userID, name, price, qty, description, category, images } = req.body;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const [result] = await db.execute(
|
||||||
|
`INSERT INTO Product (Name, Price, StockQuantity, UserID, Description, CategoryID) VALUES (?, ?, ?, ?, ?, ?)`,
|
||||||
|
[name, price, qty, userID, description, category]
|
||||||
|
);
|
||||||
|
|
||||||
|
const productID = result.insertId;
|
||||||
|
if (images && images.length > 0) {
|
||||||
|
const imageInsertPromises = images.map((imagePath) =>
|
||||||
|
db.execute(`INSERT INTO Image_URL (URL, ProductID) VALUES (?, ?)`, [
|
||||||
|
imagePath,
|
||||||
|
productID,
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
|
await Promise.all(imageInsertPromises); //perallel
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
message: "Product and images added successfully",
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error adding product or images:", error);
|
||||||
|
console.log(error);
|
||||||
|
return res.json({ error: "Could not add product or images" });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.addFavorite = async (req, res) => {
|
||||||
|
const { userID, productID } = req.body;
|
||||||
|
console.log(userID);
|
||||||
|
try {
|
||||||
|
// Use parameterized query to prevent SQL injection
|
||||||
|
const [result] = await db.execute(
|
||||||
|
`INSERT INTO Favorites (UserID, ProductID) VALUES (?, ?)`,
|
||||||
|
[userID, productID]
|
||||||
|
);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
message: "Product added to favorites successfully",
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error adding favorite product:", error);
|
||||||
|
return res.json({ error: "Could not add favorite product" });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.removeFavorite = async (req, res) => {
|
||||||
|
const { userID, productID } = req.body;
|
||||||
|
console.log(userID);
|
||||||
|
try {
|
||||||
|
// Use parameterized query to prevent SQL injection
|
||||||
|
const [result] = await db.execute(
|
||||||
|
`DELETE FROM Favorites WHERE UserID = ? AND ProductID = ?`,
|
||||||
|
[userID, productID]
|
||||||
|
);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
message: "Product removed from favorites successfully",
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error removing favorite product:", error);
|
||||||
|
return res.json({ error: "Could not remove favorite product" });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.getFavorites = async (req, res) => {
|
||||||
|
const { userID } = req.body;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const [favorites] = await db.execute(
|
||||||
|
`
|
||||||
|
SELECT
|
||||||
|
p.ProductID,
|
||||||
|
p.Name,
|
||||||
|
p.Description,
|
||||||
|
p.Price,
|
||||||
|
p.CategoryID,
|
||||||
|
p.UserID,
|
||||||
|
p.Date,
|
||||||
|
u.Name AS SellerName,
|
||||||
|
MIN(i.URL) AS image_url
|
||||||
|
FROM Favorites f
|
||||||
|
JOIN Product p ON f.ProductID = p.ProductID
|
||||||
|
JOIN User u ON p.UserID = u.UserID
|
||||||
|
LEFT JOIN Image_URL i ON p.ProductID = i.ProductID
|
||||||
|
WHERE f.UserID = ?
|
||||||
|
GROUP BY
|
||||||
|
p.ProductID,
|
||||||
|
p.Name,
|
||||||
|
p.Description,
|
||||||
|
p.Price,
|
||||||
|
p.CategoryID,
|
||||||
|
p.UserID,
|
||||||
|
p.Date,
|
||||||
|
u.Name;
|
||||||
|
`,
|
||||||
|
[userID]
|
||||||
|
);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
favorites: favorites,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error retrieving favorites:", error);
|
||||||
|
res.status(500).json({ error: "Could not retrieve favorite products" });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Get all products along with their image URLs
|
||||||
|
exports.getAllProducts = async (req, res) => {
|
||||||
|
try {
|
||||||
|
const [data, fields] = await db.execute(`
|
||||||
|
SELECT
|
||||||
|
P.ProductID,
|
||||||
|
P.Name AS ProductName,
|
||||||
|
P.Price,
|
||||||
|
P.Date AS DateUploaded,
|
||||||
|
U.Name AS SellerName,
|
||||||
|
MIN(I.URL) AS ProductImage,
|
||||||
|
C.Name AS Category
|
||||||
|
FROM Product P
|
||||||
|
JOIN Image_URL I ON P.ProductID = I.ProductID
|
||||||
|
JOIN User U ON P.UserID = U.UserID
|
||||||
|
JOIN Category C ON P.CategoryID = C.CategoryID
|
||||||
|
GROUP BY
|
||||||
|
P.ProductID,
|
||||||
|
P.Name,
|
||||||
|
P.Price,
|
||||||
|
P.Date,
|
||||||
|
U.Name,
|
||||||
|
C.Name;
|
||||||
|
`);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
message: "Products fetched successfully",
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error finding products:", error);
|
||||||
|
return res.status(500).json({
|
||||||
|
found: false,
|
||||||
|
error: "Database error occurred",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.getProductById = async (req, res) => {
|
||||||
|
const { id } = req.params;
|
||||||
|
console.log("Received Product ID:", id);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const [data] = await db.execute(
|
||||||
|
`
|
||||||
|
SELECT p.*,U.Name AS SellerName,U.Email as SellerEmail,U.Phone as SellerPhone, i.URL AS image_url
|
||||||
|
FROM Product p
|
||||||
|
LEFT JOIN Image_URL i ON p.ProductID = i.ProductID
|
||||||
|
JOIN User U ON p.UserID = U.UserID
|
||||||
|
WHERE p.ProductID = ?
|
||||||
|
`,
|
||||||
|
[id]
|
||||||
|
);
|
||||||
|
|
||||||
|
// Log raw data for debugging
|
||||||
|
console.log("Raw Database Result:", data);
|
||||||
|
|
||||||
|
if (data.length === 0) {
|
||||||
|
console.log("No product found with ID:", id);
|
||||||
|
return res.status(404).json({
|
||||||
|
success: false,
|
||||||
|
message: "Product not found",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Collect all image URLs
|
||||||
|
const images = data
|
||||||
|
.map((row) => row.image_url)
|
||||||
|
.filter((url) => url !== null);
|
||||||
|
|
||||||
|
// Create product object with all details from first row and collected images
|
||||||
|
const product = {
|
||||||
|
...data[0], // Base product details
|
||||||
|
images: images, // Collected image URLs
|
||||||
|
};
|
||||||
|
|
||||||
|
// Log processed product for debugging
|
||||||
|
console.log("Processed Product:", product);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
message: "Product fetched successfully",
|
||||||
|
data: product,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Full Error Details:", error);
|
||||||
|
return res.status(500).json({
|
||||||
|
success: false,
|
||||||
|
message: "Database error occurred",
|
||||||
|
error: error.message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.getProductWithPagination = async (req, res) => {
|
||||||
|
const limit = +req.query.limit;
|
||||||
|
const page = +req.query.page;
|
||||||
|
|
||||||
|
const offset = (page - 1) * limit;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const [data, fields] = await db.execute(
|
||||||
|
`
|
||||||
|
SELECT
|
||||||
|
P.ProductID,
|
||||||
|
P.Name AS ProductName,
|
||||||
|
P.Price,
|
||||||
|
P.Date AS DateUploaded,
|
||||||
|
U.Name AS SellerName,
|
||||||
|
MIN(I.URL) AS ProductImage,
|
||||||
|
C.Name AS Category
|
||||||
|
FROM Product P
|
||||||
|
LEFT JOIN Image_URL I ON P.ProductID = I.ProductID
|
||||||
|
LEFT JOIN User U ON P.UserID = U.UserID
|
||||||
|
LEFT JOIN Category C ON P.CategoryID = C.CategoryID
|
||||||
|
GROUP BY
|
||||||
|
P.ProductID,
|
||||||
|
P.Name,
|
||||||
|
P.Price,
|
||||||
|
P.Date,
|
||||||
|
U.Name,
|
||||||
|
C.Name
|
||||||
|
ORDER BY P.ProductID ASC
|
||||||
|
LIMIT ? OFFSET ?
|
||||||
|
`,
|
||||||
|
[limit.toString(), offset.toString()]
|
||||||
|
);
|
||||||
|
|
||||||
|
const [result] = await db.execute(
|
||||||
|
`SELECT COUNT(*) AS totalProd FROM Product`
|
||||||
|
);
|
||||||
|
const { totalProd } = result[0];
|
||||||
|
|
||||||
|
return res.json({ totalProd, products: data });
|
||||||
|
} catch (error) {
|
||||||
|
res.json({ error: "Error fetching products!" });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.removeProduct = async (req, res) => {
|
||||||
|
const { id } = req.params;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const [result] = await db.execute(
|
||||||
|
`DELETE FROM Product WHERE ProductID = ?`,
|
||||||
|
[id]
|
||||||
|
);
|
||||||
|
res.json({ message: "Delete product successfully!" });
|
||||||
|
} catch (error) {
|
||||||
|
res.json({ error: "Cannot remove product from database!" });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// db_con.query(
|
||||||
|
// "SELECT ProductID FROM product WHERE ProductID = ?",
|
||||||
|
// [productID],
|
||||||
|
// (err, results) => {
|
||||||
|
// if (err) {
|
||||||
|
// console.error("Error checking product:", err);
|
||||||
|
// return res.json({ error: "Database error" });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (results.length === 0) {
|
||||||
|
// return res.json({ error: "Product does not exist" });
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
|
||||||
|
// db_con.query(
|
||||||
|
// "INSERT INTO Favorites (UserID, ProductID) VALUES (?, ?)",
|
||||||
|
// [userID, productID],
|
||||||
|
// (err, result) => {
|
||||||
|
// if (err) {
|
||||||
|
// console.error("Error adding favorite product:", err);
|
||||||
|
// return res.json({ error: "Could not add favorite product" });
|
||||||
|
// }
|
||||||
|
// res.json({
|
||||||
|
// success: true,
|
||||||
|
// message: "Product added to favorites successfully",
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
// );
|
||||||
53
controllers/recommendation.js
Normal file
53
controllers/recommendation.js
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
const db = require("../utils/database");
|
||||||
|
|
||||||
|
// TODO: Get the recommondaed product given the userID
|
||||||
|
exports.RecommondationByUserId = async (req, res) => {
|
||||||
|
const { id } = req.body;
|
||||||
|
try {
|
||||||
|
const [data, fields] = await db.execute(
|
||||||
|
`
|
||||||
|
WITH RankedImages AS (
|
||||||
|
SELECT
|
||||||
|
P.ProductID,
|
||||||
|
P.Name AS ProductName,
|
||||||
|
P.Price,
|
||||||
|
P.Date AS DateUploaded,
|
||||||
|
U.Name AS SellerName,
|
||||||
|
I.URL AS ProductImage,
|
||||||
|
C.Name AS Category,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY P.ProductID ORDER BY I.URL) AS RowNum
|
||||||
|
FROM Product P
|
||||||
|
JOIN Image_URL I ON P.ProductID = I.ProductID
|
||||||
|
JOIN User U ON P.UserID = U.UserID
|
||||||
|
JOIN Category C ON P.CategoryID = C.CategoryID
|
||||||
|
JOIN Recommendation R ON P.ProductID = R.RecommendedProductID
|
||||||
|
WHERE R.UserID = ?
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
ProductID,
|
||||||
|
ProductName,
|
||||||
|
Price,
|
||||||
|
DateUploaded,
|
||||||
|
SellerName,
|
||||||
|
ProductImage,
|
||||||
|
Category
|
||||||
|
FROM RankedImages
|
||||||
|
WHERE RowNum = 1;
|
||||||
|
`,
|
||||||
|
[id],
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(data);
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
message: "Products fetched successfully",
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error finding products:", error);
|
||||||
|
return res.status(500).json({
|
||||||
|
found: false,
|
||||||
|
error: "Database error occurred",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
302
controllers/review.js
Normal file
302
controllers/review.js
Normal file
@@ -0,0 +1,302 @@
|
|||||||
|
const db = require("../utils/database");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get reviews for a specific product
|
||||||
|
* Returns both reviews for the product and reviews by the product owner for other products
|
||||||
|
*/
|
||||||
|
exports.getReviews = async (req, res) => {
|
||||||
|
const { id } = req.params;
|
||||||
|
console.log("Received Product ID:", id);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// First query: Get reviews for this specific product
|
||||||
|
const [productReviews] = await db.execute(
|
||||||
|
`SELECT
|
||||||
|
R.ReviewID,
|
||||||
|
R.UserID,
|
||||||
|
R.ProductID,
|
||||||
|
R.Comment,
|
||||||
|
R.Rating,
|
||||||
|
R.Date AS ReviewDate,
|
||||||
|
U.Name AS ReviewerName,
|
||||||
|
P.Name AS ProductName,
|
||||||
|
'product' AS ReviewType
|
||||||
|
FROM Review R
|
||||||
|
JOIN User U ON R.UserID = U.UserID
|
||||||
|
JOIN Product P ON R.ProductID = P.ProductID
|
||||||
|
WHERE R.ProductID = ?`,
|
||||||
|
[id],
|
||||||
|
);
|
||||||
|
|
||||||
|
// // Second query: Get reviews written by the product owner for other products
|
||||||
|
// const [sellerReviews] = await db.execute(
|
||||||
|
// `SELECT
|
||||||
|
// R.ReviewID,
|
||||||
|
// R.UserID,
|
||||||
|
// R.ProductID,
|
||||||
|
// R.Comment,
|
||||||
|
// R.Rating,
|
||||||
|
// R.Date AS ReviewDate,
|
||||||
|
// U.Name AS ReviewerName,
|
||||||
|
// P.Name AS ProductName,
|
||||||
|
// 'seller' AS ReviewType
|
||||||
|
// FROM Review R
|
||||||
|
// JOIN User U ON R.UserID = U.UserID
|
||||||
|
// JOIN Product P ON R.ProductID = P.ProductID
|
||||||
|
// WHERE R.UserID = (
|
||||||
|
// SELECT UserID
|
||||||
|
// FROM Product
|
||||||
|
// WHERE ProductID = ?
|
||||||
|
// )
|
||||||
|
// AND R.ProductID != ?`,
|
||||||
|
// [id, id],
|
||||||
|
// );
|
||||||
|
|
||||||
|
// Combine the results
|
||||||
|
const combinedReviews = [...productReviews];
|
||||||
|
|
||||||
|
// Log data for debugging
|
||||||
|
console.log("Combined Reviews:", combinedReviews);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
message: "Reviews fetched successfully",
|
||||||
|
data: combinedReviews,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Full Error Details:", error);
|
||||||
|
return res.status(500).json({
|
||||||
|
success: false,
|
||||||
|
message: "Database error occurred",
|
||||||
|
error: error.message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Submit a new review for a product
|
||||||
|
*/
|
||||||
|
exports.submitReview = async (req, res) => {
|
||||||
|
const { productId, userId, rating, comment } = req.body;
|
||||||
|
|
||||||
|
// Validate required fields
|
||||||
|
if (!productId || !userId || !rating || !comment) {
|
||||||
|
return res.status(400).json({
|
||||||
|
success: false,
|
||||||
|
message: "Missing required fields",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate rating is between 1 and 5
|
||||||
|
if (rating < 1 || rating > 5) {
|
||||||
|
return res.status(400).json({
|
||||||
|
success: false,
|
||||||
|
message: "Rating must be between 1 and 5",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Check if user has already reviewed this product
|
||||||
|
const [existingReview] = await db.execute(
|
||||||
|
`SELECT ReviewID FROM Review WHERE ProductID = ? AND UserID = ?`,
|
||||||
|
[productId, userId],
|
||||||
|
);
|
||||||
|
|
||||||
|
if (existingReview.length > 0) {
|
||||||
|
return res.status(400).json({
|
||||||
|
success: false,
|
||||||
|
message: "You have already reviewed this product",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if user is trying to review their own product
|
||||||
|
const [productOwner] = await db.execute(
|
||||||
|
`SELECT UserID FROM Product WHERE ProductID = ?`,
|
||||||
|
[productId],
|
||||||
|
);
|
||||||
|
|
||||||
|
if (productOwner.length > 0 && productOwner[0].UserID === userId) {
|
||||||
|
return res.status(400).json({
|
||||||
|
success: false,
|
||||||
|
message: "You cannot review your own product",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert the review into the database
|
||||||
|
const [result] = await db.execute(
|
||||||
|
`INSERT INTO Review (
|
||||||
|
ProductID,
|
||||||
|
UserID,
|
||||||
|
Rating,
|
||||||
|
Comment,
|
||||||
|
Date
|
||||||
|
) VALUES (?, ?, ?, ?, NOW())`,
|
||||||
|
[productId, userId, rating, comment],
|
||||||
|
);
|
||||||
|
|
||||||
|
// Get the inserted review id
|
||||||
|
const reviewId = result.insertId;
|
||||||
|
|
||||||
|
// Fetch the newly created review to return to client
|
||||||
|
const [newReview] = await db.execute(
|
||||||
|
`SELECT
|
||||||
|
R.ReviewID,
|
||||||
|
R.ProductID,
|
||||||
|
R.UserID,
|
||||||
|
R.Rating,
|
||||||
|
R.Comment,
|
||||||
|
R.Date AS ReviewDate,
|
||||||
|
U.Name AS ReviewerName,
|
||||||
|
P.Name AS ProductName
|
||||||
|
FROM Review R
|
||||||
|
JOIN User U ON R.UserID = U.UserID
|
||||||
|
JOIN Product P ON R.ProductID = P.ProductID
|
||||||
|
WHERE R.ReviewID = ?`,
|
||||||
|
[reviewId],
|
||||||
|
);
|
||||||
|
|
||||||
|
res.status(201).json({
|
||||||
|
success: true, // Fixed from false to true
|
||||||
|
message: "Review submitted successfully",
|
||||||
|
data: newReview[0],
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error submitting review:", error);
|
||||||
|
return res.status(500).json({
|
||||||
|
success: false,
|
||||||
|
message: "Database error occurred",
|
||||||
|
error: error.message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Update an existing review
|
||||||
|
// */
|
||||||
|
// exports.updateReview = async (req, res) => {
|
||||||
|
// const { reviewId } = req.params;
|
||||||
|
// const { rating, comment } = req.body;
|
||||||
|
// const userId = req.body.userId; // Assuming you have middleware that validates the user
|
||||||
|
|
||||||
|
// // Validate required fields
|
||||||
|
// if (!reviewId || !rating || !comment) {
|
||||||
|
// return res.status(400).json({
|
||||||
|
// success: false,
|
||||||
|
// message: "Missing required fields",
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Validate rating is between 1 and 5
|
||||||
|
// if (rating < 1 || rating > 5) {
|
||||||
|
// return res.status(400).json({
|
||||||
|
// success: false,
|
||||||
|
// message: "Rating must be between 1 and 5",
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// // Check if review exists and belongs to the user
|
||||||
|
// const [existingReview] = await db.execute(
|
||||||
|
// `SELECT ReviewID, UserID FROM Review WHERE ReviewID = ?`,
|
||||||
|
// [reviewId],
|
||||||
|
// );
|
||||||
|
|
||||||
|
// if (existingReview.length === 0) {
|
||||||
|
// return res.status(404).json({
|
||||||
|
// success: false,
|
||||||
|
// message: "Review not found",
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (existingReview[0].UserID !== userId) {
|
||||||
|
// return res.status(403).json({
|
||||||
|
// success: false,
|
||||||
|
// message: "You can only update your own reviews",
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Update the review
|
||||||
|
// await db.execute(
|
||||||
|
// `UPDATE Review
|
||||||
|
// SET Rating = ?, Comment = ?, Date = NOW()
|
||||||
|
// WHERE ReviewID = ?`,
|
||||||
|
// [rating, comment, reviewId],
|
||||||
|
// );
|
||||||
|
|
||||||
|
// // Fetch the updated review
|
||||||
|
// const [updatedReview] = await db.execute(
|
||||||
|
// `SELECT
|
||||||
|
// R.ReviewID,
|
||||||
|
// R.ProductID,
|
||||||
|
// R.UserID,
|
||||||
|
// R.Rating,
|
||||||
|
// R.Comment,
|
||||||
|
// R.Date AS ReviewDate,
|
||||||
|
// U.Name AS ReviewerName,
|
||||||
|
// P.Name AS ProductName
|
||||||
|
// FROM Review R
|
||||||
|
// JOIN User U ON R.UserID = U.UserID
|
||||||
|
// JOIN Product P ON R.ProductID = P.ProductID
|
||||||
|
// WHERE R.ReviewID = ?`,
|
||||||
|
// [reviewId],
|
||||||
|
// );
|
||||||
|
|
||||||
|
// res.json({
|
||||||
|
// success: true,
|
||||||
|
// message: "Review updated successfully",
|
||||||
|
// data: updatedReview[0],
|
||||||
|
// });
|
||||||
|
// } catch (error) {
|
||||||
|
// console.error("Error updating review:", error);
|
||||||
|
// return res.status(500).json({
|
||||||
|
// success: false,
|
||||||
|
// message: "Database error occurred",
|
||||||
|
// error: error.message,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Delete a review
|
||||||
|
// */
|
||||||
|
// exports.deleteReview = async (req, res) => {
|
||||||
|
// const { reviewId } = req.params;
|
||||||
|
// const userId = req.body.userId; // Assuming you have middleware that validates the user
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// // Check if review exists and belongs to the user
|
||||||
|
// const [existingReview] = await db.execute(
|
||||||
|
// `SELECT ReviewID, UserID FROM Review WHERE ReviewID = ?`,
|
||||||
|
// [reviewId],
|
||||||
|
// );
|
||||||
|
|
||||||
|
// if (existingReview.length === 0) {
|
||||||
|
// return res.status(404).json({
|
||||||
|
// success: false,
|
||||||
|
// message: "Review not found",
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (existingReview[0].UserID !== userId) {
|
||||||
|
// return res.status(403).json({
|
||||||
|
// success: false,
|
||||||
|
// message: "You can only delete your own reviews",
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Delete the review
|
||||||
|
// await db.execute(`DELETE FROM Review WHERE ReviewID = ?`, [reviewId]);
|
||||||
|
|
||||||
|
// res.json({
|
||||||
|
// success: true,
|
||||||
|
// message: "Review deleted successfully",
|
||||||
|
// });
|
||||||
|
// } catch (error) {
|
||||||
|
// console.error("Error deleting review:", error);
|
||||||
|
// return res.status(500).json({
|
||||||
|
// success: false,
|
||||||
|
// message: "Database error occurred",
|
||||||
|
// error: error.message,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// };
|
||||||
164
controllers/search.js
Normal file
164
controllers/search.js
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
const db = require("../utils/database");
|
||||||
|
|
||||||
|
exports.searchProductsByName = async (req, res) => {
|
||||||
|
const { name } = req.query;
|
||||||
|
|
||||||
|
if (name.length === 0) {
|
||||||
|
console.log("Searching for products with no name", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Searching for products with name:", name);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Modify SQL to return all products when no search term is provided
|
||||||
|
const sql = `
|
||||||
|
SELECT p.*, i.URL as image
|
||||||
|
FROM Product p
|
||||||
|
LEFT JOIN Image_URL i ON p.ProductID = i.ProductID
|
||||||
|
${name ? "WHERE p.Name LIKE ?" : ""}
|
||||||
|
ORDER BY p.ProductID
|
||||||
|
`;
|
||||||
|
|
||||||
|
const params = name ? [`%${name}%`] : [];
|
||||||
|
console.log("Executing SQL:", sql);
|
||||||
|
console.log("With parameters:", params);
|
||||||
|
|
||||||
|
const [data] = await db.execute(sql, params);
|
||||||
|
|
||||||
|
console.log("Raw Database Result:", data);
|
||||||
|
|
||||||
|
if (data.length === 0) {
|
||||||
|
console.log("No products found matching:", name);
|
||||||
|
return res.status(404).json({
|
||||||
|
success: false,
|
||||||
|
message: "No products found matching your search",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group products by ProductID to handle multiple images per product
|
||||||
|
const productsMap = new Map();
|
||||||
|
|
||||||
|
data.forEach((row) => {
|
||||||
|
if (!productsMap.has(row.ProductID)) {
|
||||||
|
const product = {
|
||||||
|
ProductID: row.ProductID,
|
||||||
|
Name: row.Name,
|
||||||
|
Description: row.Description,
|
||||||
|
Price: row.Price,
|
||||||
|
images: row.image,
|
||||||
|
};
|
||||||
|
productsMap.set(row.ProductID, product);
|
||||||
|
} else if (row.image_url) {
|
||||||
|
productsMap.get(row.ProductID).images.push(row.image_url);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const products = Array.from(productsMap.values());
|
||||||
|
|
||||||
|
console.log("Processed Products:", products);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
message: "Products fetched successfully",
|
||||||
|
data: products,
|
||||||
|
count: products.length,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Database Error:", error);
|
||||||
|
return res.status(500).json({
|
||||||
|
success: false,
|
||||||
|
message: "Database error occurred",
|
||||||
|
error: error.message || "Unknown database error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// exports.searchProductsByName = async (req, res) => {
|
||||||
|
// const { name } = req.query;
|
||||||
|
|
||||||
|
// // Add better validation and error handling
|
||||||
|
// if (!name || typeof name !== "string") {
|
||||||
|
// return res.status(400).json({
|
||||||
|
// success: false,
|
||||||
|
// message: "Valid search term is required",
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// console.log("Searching for products with name:", name);
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// // Log the SQL query and parameters for debugging
|
||||||
|
// const sql = `
|
||||||
|
// SELECT p.*, i.URL AS image_url
|
||||||
|
// FROM Product p
|
||||||
|
// LEFT JOIN Image_URL i ON p.ProductID = i.ProductID
|
||||||
|
// WHERE p.Name LIKE ?
|
||||||
|
// `;
|
||||||
|
// const params = [`%${name}%`];
|
||||||
|
// console.log("Executing SQL:", sql);
|
||||||
|
// console.log("With parameters:", params);
|
||||||
|
|
||||||
|
// const [data] = await db.execute(sql, params);
|
||||||
|
|
||||||
|
// // Log raw data for debugging
|
||||||
|
// console.log("Raw Database Result:", data);
|
||||||
|
|
||||||
|
// if (data.length === 0) {
|
||||||
|
// console.log("No products found matching:", name);
|
||||||
|
// return res.status(404).json({
|
||||||
|
// success: false,
|
||||||
|
// message: "No products found matching your search",
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Group products by ProductID to handle multiple images per product
|
||||||
|
// const productsMap = new Map();
|
||||||
|
|
||||||
|
// data.forEach((row) => {
|
||||||
|
// if (!productsMap.has(row.ProductID)) {
|
||||||
|
// // Create a clean object without circular references
|
||||||
|
// const product = {
|
||||||
|
// ProductID: row.ProductID,
|
||||||
|
// Name: row.Name,
|
||||||
|
// Description: row.Description,
|
||||||
|
// Price: row.Price,
|
||||||
|
// // Add any other product fields you need
|
||||||
|
// images: row.image_url ? [row.image_url] : [],
|
||||||
|
// };
|
||||||
|
// productsMap.set(row.ProductID, product);
|
||||||
|
// } else if (row.image_url) {
|
||||||
|
// // Add additional image to existing product
|
||||||
|
// productsMap.get(row.ProductID).images.push(row.image_url);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // Convert map to array of products
|
||||||
|
// const products = Array.from(productsMap.values());
|
||||||
|
|
||||||
|
// // Log processed products for debugging
|
||||||
|
// console.log("Processed Products:", products);
|
||||||
|
|
||||||
|
// res.json({
|
||||||
|
// success: true,
|
||||||
|
// message: "Products fetched successfully",
|
||||||
|
// data: products,
|
||||||
|
// count: products.length,
|
||||||
|
// });
|
||||||
|
// } catch (error) {
|
||||||
|
// // Enhanced error logging
|
||||||
|
// console.error("Database Error Details:", {
|
||||||
|
// message: error.message,
|
||||||
|
// code: error.code,
|
||||||
|
// errno: error.errno,
|
||||||
|
// sqlState: error.sqlState,
|
||||||
|
// sqlMessage: error.sqlMessage,
|
||||||
|
// sql: error.sql,
|
||||||
|
// });
|
||||||
|
|
||||||
|
// return res.status(500).json({
|
||||||
|
// success: false,
|
||||||
|
// message: "Database error occurred",
|
||||||
|
// error: error.message || "Unknown database error",
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// };
|
||||||
365
controllers/user.js
Normal file
365
controllers/user.js
Normal file
@@ -0,0 +1,365 @@
|
|||||||
|
const crypto = require("crypto");
|
||||||
|
const db = require("../utils/database");
|
||||||
|
const { sendVerificationEmail } = require("../utils/helper");
|
||||||
|
|
||||||
|
exports.sendVerificationCode = async (req, res) => {
|
||||||
|
const { email } = req.body;
|
||||||
|
|
||||||
|
if (!email) {
|
||||||
|
return res.status(400).json({ error: "Email is required" });
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Generate a random 6-digit code
|
||||||
|
const verificationCode = crypto.randomInt(100000, 999999).toString();
|
||||||
|
console.log(
|
||||||
|
`Generated verification code for ${email}: ${verificationCode}`
|
||||||
|
);
|
||||||
|
|
||||||
|
// Check if email already exists in verification table
|
||||||
|
const [results, fields] = await db.execute(
|
||||||
|
"SELECT * FROM AuthVerification WHERE Email = ?",
|
||||||
|
[email]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.length > 0) {
|
||||||
|
// Update existing record
|
||||||
|
const [result] = await db.execute(
|
||||||
|
`UPDATE AuthVerification SET VerificationCode = ?, Authenticated = FALSE, Date = CURRENT_TIMESTAMP
|
||||||
|
WHERE Email = ?`,
|
||||||
|
[verificationCode, email]
|
||||||
|
);
|
||||||
|
|
||||||
|
// Send email and respond
|
||||||
|
await sendVerificationEmail(email, verificationCode);
|
||||||
|
res.json({ success: true, message: "Verification code sent" });
|
||||||
|
} else {
|
||||||
|
// Insert new record
|
||||||
|
const [result] = await db.execute(
|
||||||
|
"INSERT INTO AuthVerification (Email, VerificationCode, Authenticated) VALUES (?, ?, FALSE)",
|
||||||
|
[email, verificationCode]
|
||||||
|
);
|
||||||
|
// Send email and respond
|
||||||
|
await sendVerificationEmail(email, verificationCode);
|
||||||
|
res.json({ success: true, message: "Verification code sent" });
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error:", error);
|
||||||
|
res.status(500).json({ error: "Server error" });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.verifyCode = async (req, res) => {
|
||||||
|
const { email, code } = req.body;
|
||||||
|
|
||||||
|
if (!email || !code) {
|
||||||
|
return res.status(400).json({ error: "Email and code are required" });
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Attempting to verify code for ${email}: ${code}`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Check verification code
|
||||||
|
const [results, fields] = await db.execute(
|
||||||
|
"SELECT * FROM AuthVerification WHERE Email = ? AND VerificationCode = ? AND Authenticated = 0 AND Date > DATE_SUB(NOW(), INTERVAL 15 MINUTE)",
|
||||||
|
[email, code]
|
||||||
|
);
|
||||||
|
if (results.length === 0) {
|
||||||
|
console.log(`Invalid or expired verification code for email ${email}`);
|
||||||
|
return res
|
||||||
|
.status(400)
|
||||||
|
.json({ error: "Invalid or expired verification code" });
|
||||||
|
}
|
||||||
|
|
||||||
|
const userId = results[0].UserID;
|
||||||
|
|
||||||
|
// Mark as authenticated
|
||||||
|
const [result] = await db.execute(
|
||||||
|
"UPDATE AuthVerification SET Authenticated = TRUE WHERE Email = ?",
|
||||||
|
[email]
|
||||||
|
);
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
message: "Verification successful",
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error: ", error);
|
||||||
|
res.status(500).json({ error: "Database error!" });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.completeSignUp = async (req, res) => {
|
||||||
|
const data = req.body;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const [results, fields] = await db.execute(
|
||||||
|
`SELECT * FROM AuthVerification WHERE Email = ? AND Authenticated = 1;`,
|
||||||
|
[data.email]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (results.length === 0) {
|
||||||
|
return res.status(400).json({ error: "Email not verified" });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the user
|
||||||
|
const [createResult] = await db.execute(
|
||||||
|
`INSERT INTO User (Name, Email, UCID, Password, Phone, Address)
|
||||||
|
VALUES ('${data.name}', '${data.email}', '${data.UCID}', '${data.password}', '${data.phone}', '${data.address}')`
|
||||||
|
);
|
||||||
|
|
||||||
|
// Insert role using the user's ID
|
||||||
|
const [insertResult] = await db.execute(
|
||||||
|
`INSERT INTO UserRole (UserID, Client, Admin)
|
||||||
|
VALUES (LAST_INSERT_ID(), ${data.client || true}, ${
|
||||||
|
data.admin || false
|
||||||
|
})`
|
||||||
|
);
|
||||||
|
|
||||||
|
// Delete verification record
|
||||||
|
const [deleteResult] = await db.execute(
|
||||||
|
`DELETE FROM AuthVerification WHERE Email = '${data.email}'`
|
||||||
|
);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
message: "User registration completed successfully",
|
||||||
|
name: data.name,
|
||||||
|
email: data.email,
|
||||||
|
UCID: data.UCID,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error: ", error);
|
||||||
|
res.status(500).json({ error: "Database error!" });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.doLogin = async (req, res) => {
|
||||||
|
const { email, password } = req.body;
|
||||||
|
|
||||||
|
// Input validation
|
||||||
|
if (!email || !password) {
|
||||||
|
return res.status(400).json({
|
||||||
|
found: false,
|
||||||
|
error: "Email and password are required",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Query to find user with matching email
|
||||||
|
const query = "SELECT * FROM User WHERE email = ?";
|
||||||
|
const [data, fields] = await db.execute(query, [email]);
|
||||||
|
|
||||||
|
// Check if user was found
|
||||||
|
if (data && data.length > 0) {
|
||||||
|
const user = data[0];
|
||||||
|
|
||||||
|
// Verify password match
|
||||||
|
if (user.Password === password) {
|
||||||
|
// Consider using bcrypt for secure password comparison
|
||||||
|
// Return user data without password
|
||||||
|
return res.json({
|
||||||
|
found: true,
|
||||||
|
userID: user.UserID,
|
||||||
|
name: user.Name,
|
||||||
|
email: user.Email,
|
||||||
|
UCID: user.UCID,
|
||||||
|
phone: user.Phone,
|
||||||
|
address: user.Address,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Password doesn't match
|
||||||
|
return res.json({
|
||||||
|
found: false,
|
||||||
|
error: "Invalid email or password",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// User not found
|
||||||
|
return res.json({
|
||||||
|
found: false,
|
||||||
|
error: "Invalid email or password",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error logging in:", error);
|
||||||
|
return res.status(500).json({
|
||||||
|
found: false,
|
||||||
|
error: "Database error occurred",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.getAllUser = async (req, res) => {
|
||||||
|
try {
|
||||||
|
const [users, fields] = await db.execute("SELECT * FROM User;");
|
||||||
|
res.json({ Users: users });
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Errors: ", error);
|
||||||
|
return res.status(500).json({ error: "\nCould not fetch users!" });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.findUserByEmail = async (req, res) => {
|
||||||
|
const { email } = req.body;
|
||||||
|
|
||||||
|
// Input validation
|
||||||
|
if (!email) {
|
||||||
|
return res.status(400).json({
|
||||||
|
found: false,
|
||||||
|
error: "Email is required",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Query to find user with matching email and password
|
||||||
|
const query = "SELECT * FROM User WHERE email = ?";
|
||||||
|
const [data, fields] = await db.execute(query, [email]);
|
||||||
|
|
||||||
|
// Check if user was found
|
||||||
|
if (data && data.length > 0) {
|
||||||
|
console.log(data);
|
||||||
|
const user = data[0];
|
||||||
|
|
||||||
|
// Return all user data except password
|
||||||
|
return res.json({
|
||||||
|
found: true,
|
||||||
|
userID: user.UserID,
|
||||||
|
name: user.Name,
|
||||||
|
email: user.Email,
|
||||||
|
UCID: user.UCID,
|
||||||
|
phone: user.Phone,
|
||||||
|
address: user.Address,
|
||||||
|
password: user.Password,
|
||||||
|
// Include any other fields your user might have
|
||||||
|
// Make sure the field names match exactly with your database column names
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// User not found or invalid credentials
|
||||||
|
return res.json({
|
||||||
|
found: false,
|
||||||
|
error: "Invalid email or password",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error finding user:", error);
|
||||||
|
return res.status(500).json({
|
||||||
|
found: false,
|
||||||
|
error: "Database error occurred",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.updateUser = async (req, res) => {
|
||||||
|
try {
|
||||||
|
const userId = req.body?.userId;
|
||||||
|
const name = req.body?.name;
|
||||||
|
const email = req.body?.email;
|
||||||
|
const phone = req.body?.phone;
|
||||||
|
const UCID = req.body?.UCID;
|
||||||
|
const address = req.body?.address;
|
||||||
|
const password = req.body?.password;
|
||||||
|
if (!userId) {
|
||||||
|
return res.status(400).json({ error: "User ID is required" });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build updateData manually
|
||||||
|
const updateData = {};
|
||||||
|
if (name) updateData.name = name;
|
||||||
|
if (email) updateData.email = email;
|
||||||
|
if (phone) updateData.phone = phone;
|
||||||
|
if (UCID) updateData.UCID = UCID;
|
||||||
|
if (address) updateData.address = address;
|
||||||
|
if (password) updateData.password = password;
|
||||||
|
if (Object.keys(updateData).length === 0) {
|
||||||
|
return res.status(400).json({ error: "No valid fields to update" });
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateFields = [];
|
||||||
|
const values = [];
|
||||||
|
|
||||||
|
Object.entries(updateData).forEach(([key, value]) => {
|
||||||
|
updateFields.push(`${key} = ?`);
|
||||||
|
values.push(value);
|
||||||
|
});
|
||||||
|
|
||||||
|
values.push(userId);
|
||||||
|
|
||||||
|
const query = `UPDATE User SET ${updateFields.join(", ")} WHERE userId = ?`;
|
||||||
|
const [updateResult] = await db.execute(query, values);
|
||||||
|
|
||||||
|
if (updateResult.affectedRows === 0) {
|
||||||
|
return res.status(404).json({ error: "User not found" });
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json({ success: true, message: "User updated successfully" });
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error updating user:", error);
|
||||||
|
return res.status(500).json({ error: "Could not update user" });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.deleteUser = async (req, res) => {
|
||||||
|
const { userId } = req.body;
|
||||||
|
|
||||||
|
if (!userId) {
|
||||||
|
return res.status(400).json({ error: "User ID is required" });
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Delete from UserRole first (assuming foreign key constraint)
|
||||||
|
const [result1] = await db.execute(
|
||||||
|
"DELETE FROM UserRole WHERE UserID = ?",
|
||||||
|
[userId]
|
||||||
|
);
|
||||||
|
|
||||||
|
// Then delete from User table
|
||||||
|
const [result2] = await db.execute("DELETE FROM User WHERE UserID = ?", [
|
||||||
|
userId,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (result2.affectedRows === 0) {
|
||||||
|
return res.status(404).json({ error: "User not found" });
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json({ success: true, message: "User deleted successfully" });
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error: ", error);
|
||||||
|
return res.status(500).json({ error: "Could not delete user!" });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.getUsersWithPagination = async (req, res) => {
|
||||||
|
const limit = +req.query.limit;
|
||||||
|
const page = +req.query.page;
|
||||||
|
|
||||||
|
const offset = (page - 1) * limit;
|
||||||
|
try {
|
||||||
|
const [users, fields] = await db.execute(
|
||||||
|
"SELECT * FROM User LIMIT ? OFFSET ?",
|
||||||
|
[limit.toString(), offset.toString()]
|
||||||
|
);
|
||||||
|
|
||||||
|
const [result] = await db.execute("SELECT COUNT(*) AS count FROM User");
|
||||||
|
const { count: total } = result[0];
|
||||||
|
|
||||||
|
res.json({ users, total });
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Errors: ", error);
|
||||||
|
return res.status(500).json({ error: "\nCould not fetch users!" });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.isAdmin = async (req, res) => {
|
||||||
|
const { id } = req.params;
|
||||||
|
try {
|
||||||
|
const [result] = await db.execute(
|
||||||
|
"SELECT R.Admin FROM marketplace.userrole R WHERE R.UserID = ?",
|
||||||
|
[id]
|
||||||
|
);
|
||||||
|
const { Admin } = result[0];
|
||||||
|
res.json({ isAdmin: Admin });
|
||||||
|
} catch (error) {
|
||||||
|
res.json({ error: "Cannot verify admin status!" });
|
||||||
|
}
|
||||||
|
};
|
||||||
56
index.js
Normal file
56
index.js
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
const express = require("express");
|
||||||
|
const cors = require("cors");
|
||||||
|
|
||||||
|
const db = require("./utils/database");
|
||||||
|
|
||||||
|
const userRouter = require("./routes/user");
|
||||||
|
const productRouter = require("./routes/product");
|
||||||
|
const searchRouter = require("./routes/search");
|
||||||
|
const recommendedRouter = require("./routes/recommendation");
|
||||||
|
const history = require("./routes/history");
|
||||||
|
const review = require("./routes/review");
|
||||||
|
const categoryRouter = require("./routes/category");
|
||||||
|
|
||||||
|
const { generateEmailTransporter } = require("./utils/mail");
|
||||||
|
const {
|
||||||
|
cleanupExpiredCodes,
|
||||||
|
checkDatabaseConnection,
|
||||||
|
} = require("./utils/helper");
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
|
||||||
|
app.use(cors());
|
||||||
|
app.use(express.json());
|
||||||
|
|
||||||
|
// Configure email transporter for Zoho
|
||||||
|
const transporter = generateEmailTransporter();
|
||||||
|
// Test the email connection
|
||||||
|
transporter
|
||||||
|
.verify()
|
||||||
|
.then(() => {
|
||||||
|
console.log("Email connection successful!");
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Email connection failed:", error);
|
||||||
|
});
|
||||||
|
|
||||||
|
checkDatabaseConnection(db);
|
||||||
|
|
||||||
|
//Routes
|
||||||
|
app.use("/api/user", userRouter);
|
||||||
|
app.use("/api/product", productRouter);
|
||||||
|
app.use("/api/search", searchRouter);
|
||||||
|
app.use("/api/engine", recommendedRouter);
|
||||||
|
app.use("/api/history", history);
|
||||||
|
app.use("/api/review", review);
|
||||||
|
app.use("/api/category", categoryRouter);
|
||||||
|
|
||||||
|
// Set up a scheduler to run cleanup every hour
|
||||||
|
clean_up_time = 30 * 60 * 1000;
|
||||||
|
setInterval(cleanupExpiredCodes, clean_up_time);
|
||||||
|
|
||||||
|
app.listen(3030, () => {
|
||||||
|
console.log(`Running Backend on http://localhost:3030/`);
|
||||||
|
console.log(`Send verification code: POST /send-verification`);
|
||||||
|
console.log(`Verify code: POST /verify-code`);
|
||||||
|
});
|
||||||
16
node_modules/.bin/mime
generated
vendored
Normal file
16
node_modules/.bin/mime
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*)
|
||||||
|
if command -v cygpath > /dev/null 2>&1; then
|
||||||
|
basedir=`cygpath -w "$basedir"`
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../mime/cli.js" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../mime/cli.js" "$@"
|
||||||
|
fi
|
||||||
17
node_modules/.bin/mime.cmd
generated
vendored
Normal file
17
node_modules/.bin/mime.cmd
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\mime\cli.js" %*
|
||||||
28
node_modules/.bin/mime.ps1
generated
vendored
Normal file
28
node_modules/.bin/mime.ps1
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../mime/cli.js" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../mime/cli.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../mime/cli.js" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../mime/cli.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
||||||
16
node_modules/.bin/nodemon
generated
vendored
Normal file
16
node_modules/.bin/nodemon
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*)
|
||||||
|
if command -v cygpath > /dev/null 2>&1; then
|
||||||
|
basedir=`cygpath -w "$basedir"`
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../nodemon/bin/nodemon.js" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../nodemon/bin/nodemon.js" "$@"
|
||||||
|
fi
|
||||||
17
node_modules/.bin/nodemon.cmd
generated
vendored
Normal file
17
node_modules/.bin/nodemon.cmd
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\nodemon\bin\nodemon.js" %*
|
||||||
28
node_modules/.bin/nodemon.ps1
generated
vendored
Normal file
28
node_modules/.bin/nodemon.ps1
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../nodemon/bin/nodemon.js" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../nodemon/bin/nodemon.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../nodemon/bin/nodemon.js" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../nodemon/bin/nodemon.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
||||||
16
node_modules/.bin/nodetouch
generated
vendored
Normal file
16
node_modules/.bin/nodetouch
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*)
|
||||||
|
if command -v cygpath > /dev/null 2>&1; then
|
||||||
|
basedir=`cygpath -w "$basedir"`
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../touch/bin/nodetouch.js" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../touch/bin/nodetouch.js" "$@"
|
||||||
|
fi
|
||||||
17
node_modules/.bin/nodetouch.cmd
generated
vendored
Normal file
17
node_modules/.bin/nodetouch.cmd
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\touch\bin\nodetouch.js" %*
|
||||||
28
node_modules/.bin/nodetouch.ps1
generated
vendored
Normal file
28
node_modules/.bin/nodetouch.ps1
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../touch/bin/nodetouch.js" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../touch/bin/nodetouch.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../touch/bin/nodetouch.js" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../touch/bin/nodetouch.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
||||||
16
node_modules/.bin/semver
generated
vendored
Normal file
16
node_modules/.bin/semver
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||||
|
|
||||||
|
case `uname` in
|
||||||
|
*CYGWIN*|*MINGW*|*MSYS*)
|
||||||
|
if command -v cygpath > /dev/null 2>&1; then
|
||||||
|
basedir=`cygpath -w "$basedir"`
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -x "$basedir/node" ]; then
|
||||||
|
exec "$basedir/node" "$basedir/../semver/bin/semver.js" "$@"
|
||||||
|
else
|
||||||
|
exec node "$basedir/../semver/bin/semver.js" "$@"
|
||||||
|
fi
|
||||||
17
node_modules/.bin/semver.cmd
generated
vendored
Normal file
17
node_modules/.bin/semver.cmd
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
@ECHO off
|
||||||
|
GOTO start
|
||||||
|
:find_dp0
|
||||||
|
SET dp0=%~dp0
|
||||||
|
EXIT /b
|
||||||
|
:start
|
||||||
|
SETLOCAL
|
||||||
|
CALL :find_dp0
|
||||||
|
|
||||||
|
IF EXIST "%dp0%\node.exe" (
|
||||||
|
SET "_prog=%dp0%\node.exe"
|
||||||
|
) ELSE (
|
||||||
|
SET "_prog=node"
|
||||||
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
|
)
|
||||||
|
|
||||||
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\semver\bin\semver.js" %*
|
||||||
28
node_modules/.bin/semver.ps1
generated
vendored
Normal file
28
node_modules/.bin/semver.ps1
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env pwsh
|
||||||
|
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
$exe=""
|
||||||
|
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||||
|
# Fix case when both the Windows and Linux builds of Node
|
||||||
|
# are installed in the same directory
|
||||||
|
$exe=".exe"
|
||||||
|
}
|
||||||
|
$ret=0
|
||||||
|
if (Test-Path "$basedir/node$exe") {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "$basedir/node$exe" "$basedir/../semver/bin/semver.js" $args
|
||||||
|
} else {
|
||||||
|
& "$basedir/node$exe" "$basedir/../semver/bin/semver.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
} else {
|
||||||
|
# Support pipeline input
|
||||||
|
if ($MyInvocation.ExpectingInput) {
|
||||||
|
$input | & "node$exe" "$basedir/../semver/bin/semver.js" $args
|
||||||
|
} else {
|
||||||
|
& "node$exe" "$basedir/../semver/bin/semver.js" $args
|
||||||
|
}
|
||||||
|
$ret=$LASTEXITCODE
|
||||||
|
}
|
||||||
|
exit $ret
|
||||||
1558
node_modules/.package-lock.json
generated
vendored
Normal file
1558
node_modules/.package-lock.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
243
node_modules/accepts/HISTORY.md
generated
vendored
Normal file
243
node_modules/accepts/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,243 @@
|
|||||||
|
1.3.8 / 2022-02-02
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.34
|
||||||
|
- deps: mime-db@~1.51.0
|
||||||
|
* deps: negotiator@0.6.3
|
||||||
|
|
||||||
|
1.3.7 / 2019-04-29
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.6.2
|
||||||
|
- Fix sorting charset, encoding, and language with extra parameters
|
||||||
|
|
||||||
|
1.3.6 / 2019-04-28
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.24
|
||||||
|
- deps: mime-db@~1.40.0
|
||||||
|
|
||||||
|
1.3.5 / 2018-02-28
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.18
|
||||||
|
- deps: mime-db@~1.33.0
|
||||||
|
|
||||||
|
1.3.4 / 2017-08-22
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.16
|
||||||
|
- deps: mime-db@~1.29.0
|
||||||
|
|
||||||
|
1.3.3 / 2016-05-02
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.11
|
||||||
|
- deps: mime-db@~1.23.0
|
||||||
|
* deps: negotiator@0.6.1
|
||||||
|
- perf: improve `Accept` parsing speed
|
||||||
|
- perf: improve `Accept-Charset` parsing speed
|
||||||
|
- perf: improve `Accept-Encoding` parsing speed
|
||||||
|
- perf: improve `Accept-Language` parsing speed
|
||||||
|
|
||||||
|
1.3.2 / 2016-03-08
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.10
|
||||||
|
- Fix extension of `application/dash+xml`
|
||||||
|
- Update primary extension for `audio/mp4`
|
||||||
|
- deps: mime-db@~1.22.0
|
||||||
|
|
||||||
|
1.3.1 / 2016-01-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.9
|
||||||
|
- deps: mime-db@~1.21.0
|
||||||
|
|
||||||
|
1.3.0 / 2015-09-29
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.7
|
||||||
|
- deps: mime-db@~1.19.0
|
||||||
|
* deps: negotiator@0.6.0
|
||||||
|
- Fix including type extensions in parameters in `Accept` parsing
|
||||||
|
- Fix parsing `Accept` parameters with quoted equals
|
||||||
|
- Fix parsing `Accept` parameters with quoted semicolons
|
||||||
|
- Lazy-load modules from main entry point
|
||||||
|
- perf: delay type concatenation until needed
|
||||||
|
- perf: enable strict mode
|
||||||
|
- perf: hoist regular expressions
|
||||||
|
- perf: remove closures getting spec properties
|
||||||
|
- perf: remove a closure from media type parsing
|
||||||
|
- perf: remove property delete from media type parsing
|
||||||
|
|
||||||
|
1.2.13 / 2015-09-06
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.6
|
||||||
|
- deps: mime-db@~1.18.0
|
||||||
|
|
||||||
|
1.2.12 / 2015-07-30
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.4
|
||||||
|
- deps: mime-db@~1.16.0
|
||||||
|
|
||||||
|
1.2.11 / 2015-07-16
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.3
|
||||||
|
- deps: mime-db@~1.15.0
|
||||||
|
|
||||||
|
1.2.10 / 2015-07-01
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.2
|
||||||
|
- deps: mime-db@~1.14.0
|
||||||
|
|
||||||
|
1.2.9 / 2015-06-08
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.1
|
||||||
|
- perf: fix deopt during mapping
|
||||||
|
|
||||||
|
1.2.8 / 2015-06-07
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.1.0
|
||||||
|
- deps: mime-db@~1.13.0
|
||||||
|
* perf: avoid argument reassignment & argument slice
|
||||||
|
* perf: avoid negotiator recursive construction
|
||||||
|
* perf: enable strict mode
|
||||||
|
* perf: remove unnecessary bitwise operator
|
||||||
|
|
||||||
|
1.2.7 / 2015-05-10
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.5.3
|
||||||
|
- Fix media type parameter matching to be case-insensitive
|
||||||
|
|
||||||
|
1.2.6 / 2015-05-07
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.11
|
||||||
|
- deps: mime-db@~1.9.1
|
||||||
|
* deps: negotiator@0.5.2
|
||||||
|
- Fix comparing media types with quoted values
|
||||||
|
- Fix splitting media types with quoted commas
|
||||||
|
|
||||||
|
1.2.5 / 2015-03-13
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.10
|
||||||
|
- deps: mime-db@~1.8.0
|
||||||
|
|
||||||
|
1.2.4 / 2015-02-14
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Support Node.js 0.6
|
||||||
|
* deps: mime-types@~2.0.9
|
||||||
|
- deps: mime-db@~1.7.0
|
||||||
|
* deps: negotiator@0.5.1
|
||||||
|
- Fix preference sorting to be stable for long acceptable lists
|
||||||
|
|
||||||
|
1.2.3 / 2015-01-31
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.8
|
||||||
|
- deps: mime-db@~1.6.0
|
||||||
|
|
||||||
|
1.2.2 / 2014-12-30
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.7
|
||||||
|
- deps: mime-db@~1.5.0
|
||||||
|
|
||||||
|
1.2.1 / 2014-12-30
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.5
|
||||||
|
- deps: mime-db@~1.3.1
|
||||||
|
|
||||||
|
1.2.0 / 2014-12-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.5.0
|
||||||
|
- Fix list return order when large accepted list
|
||||||
|
- Fix missing identity encoding when q=0 exists
|
||||||
|
- Remove dynamic building of Negotiator class
|
||||||
|
|
||||||
|
1.1.4 / 2014-12-10
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.4
|
||||||
|
- deps: mime-db@~1.3.0
|
||||||
|
|
||||||
|
1.1.3 / 2014-11-09
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.3
|
||||||
|
- deps: mime-db@~1.2.0
|
||||||
|
|
||||||
|
1.1.2 / 2014-10-14
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.4.9
|
||||||
|
- Fix error when media type has invalid parameter
|
||||||
|
|
||||||
|
1.1.1 / 2014-09-28
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: mime-types@~2.0.2
|
||||||
|
- deps: mime-db@~1.1.0
|
||||||
|
* deps: negotiator@0.4.8
|
||||||
|
- Fix all negotiations to be case-insensitive
|
||||||
|
- Stable sort preferences of same quality according to client order
|
||||||
|
|
||||||
|
1.1.0 / 2014-09-02
|
||||||
|
==================
|
||||||
|
|
||||||
|
* update `mime-types`
|
||||||
|
|
||||||
|
1.0.7 / 2014-07-04
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix wrong type returned from `type` when match after unknown extension
|
||||||
|
|
||||||
|
1.0.6 / 2014-06-24
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.4.7
|
||||||
|
|
||||||
|
1.0.5 / 2014-06-20
|
||||||
|
==================
|
||||||
|
|
||||||
|
* fix crash when unknown extension given
|
||||||
|
|
||||||
|
1.0.4 / 2014-06-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* use `mime-types`
|
||||||
|
|
||||||
|
1.0.3 / 2014-06-11
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: negotiator@0.4.6
|
||||||
|
- Order by specificity when quality is the same
|
||||||
|
|
||||||
|
1.0.2 / 2014-05-29
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix interpretation when header not in request
|
||||||
|
* deps: pin negotiator@0.4.5
|
||||||
|
|
||||||
|
1.0.1 / 2014-01-18
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Identity encoding isn't always acceptable
|
||||||
|
* deps: negotiator@~0.4.0
|
||||||
|
|
||||||
|
1.0.0 / 2013-12-27
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Genesis
|
||||||
23
node_modules/accepts/LICENSE
generated
vendored
Normal file
23
node_modules/accepts/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
|
||||||
|
Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
'Software'), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER 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.
|
||||||
140
node_modules/accepts/README.md
generated
vendored
Normal file
140
node_modules/accepts/README.md
generated
vendored
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
# accepts
|
||||||
|
|
||||||
|
[![NPM Version][npm-version-image]][npm-url]
|
||||||
|
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||||
|
[![Node.js Version][node-version-image]][node-version-url]
|
||||||
|
[![Build Status][github-actions-ci-image]][github-actions-ci-url]
|
||||||
|
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||||
|
|
||||||
|
Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator).
|
||||||
|
Extracted from [koa](https://www.npmjs.com/package/koa) for general use.
|
||||||
|
|
||||||
|
In addition to negotiator, it allows:
|
||||||
|
|
||||||
|
- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])`
|
||||||
|
as well as `('text/html', 'application/json')`.
|
||||||
|
- Allows type shorthands such as `json`.
|
||||||
|
- Returns `false` when no types match
|
||||||
|
- Treats non-existent headers as `*`
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
This is a [Node.js](https://nodejs.org/en/) module available through the
|
||||||
|
[npm registry](https://www.npmjs.com/). Installation is done using the
|
||||||
|
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install accepts
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
```js
|
||||||
|
var accepts = require('accepts')
|
||||||
|
```
|
||||||
|
|
||||||
|
### accepts(req)
|
||||||
|
|
||||||
|
Create a new `Accepts` object for the given `req`.
|
||||||
|
|
||||||
|
#### .charset(charsets)
|
||||||
|
|
||||||
|
Return the first accepted charset. If nothing in `charsets` is accepted,
|
||||||
|
then `false` is returned.
|
||||||
|
|
||||||
|
#### .charsets()
|
||||||
|
|
||||||
|
Return the charsets that the request accepts, in the order of the client's
|
||||||
|
preference (most preferred first).
|
||||||
|
|
||||||
|
#### .encoding(encodings)
|
||||||
|
|
||||||
|
Return the first accepted encoding. If nothing in `encodings` is accepted,
|
||||||
|
then `false` is returned.
|
||||||
|
|
||||||
|
#### .encodings()
|
||||||
|
|
||||||
|
Return the encodings that the request accepts, in the order of the client's
|
||||||
|
preference (most preferred first).
|
||||||
|
|
||||||
|
#### .language(languages)
|
||||||
|
|
||||||
|
Return the first accepted language. If nothing in `languages` is accepted,
|
||||||
|
then `false` is returned.
|
||||||
|
|
||||||
|
#### .languages()
|
||||||
|
|
||||||
|
Return the languages that the request accepts, in the order of the client's
|
||||||
|
preference (most preferred first).
|
||||||
|
|
||||||
|
#### .type(types)
|
||||||
|
|
||||||
|
Return the first accepted type (and it is returned as the same text as what
|
||||||
|
appears in the `types` array). If nothing in `types` is accepted, then `false`
|
||||||
|
is returned.
|
||||||
|
|
||||||
|
The `types` array can contain full MIME types or file extensions. Any value
|
||||||
|
that is not a full MIME types is passed to `require('mime-types').lookup`.
|
||||||
|
|
||||||
|
#### .types()
|
||||||
|
|
||||||
|
Return the types that the request accepts, in the order of the client's
|
||||||
|
preference (most preferred first).
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Simple type negotiation
|
||||||
|
|
||||||
|
This simple example shows how to use `accepts` to return a different typed
|
||||||
|
respond body based on what the client wants to accept. The server lists it's
|
||||||
|
preferences in order and will get back the best match between the client and
|
||||||
|
server.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var accepts = require('accepts')
|
||||||
|
var http = require('http')
|
||||||
|
|
||||||
|
function app (req, res) {
|
||||||
|
var accept = accepts(req)
|
||||||
|
|
||||||
|
// the order of this list is significant; should be server preferred order
|
||||||
|
switch (accept.type(['json', 'html'])) {
|
||||||
|
case 'json':
|
||||||
|
res.setHeader('Content-Type', 'application/json')
|
||||||
|
res.write('{"hello":"world!"}')
|
||||||
|
break
|
||||||
|
case 'html':
|
||||||
|
res.setHeader('Content-Type', 'text/html')
|
||||||
|
res.write('<b>hello, world!</b>')
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
// the fallback is text/plain, so no need to specify it above
|
||||||
|
res.setHeader('Content-Type', 'text/plain')
|
||||||
|
res.write('hello, world!')
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
res.end()
|
||||||
|
}
|
||||||
|
|
||||||
|
http.createServer(app).listen(3000)
|
||||||
|
```
|
||||||
|
|
||||||
|
You can test this out with the cURL program:
|
||||||
|
```sh
|
||||||
|
curl -I -H'Accept: text/html' http://localhost:3000/
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[MIT](LICENSE)
|
||||||
|
|
||||||
|
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/accepts/master
|
||||||
|
[coveralls-url]: https://coveralls.io/r/jshttp/accepts?branch=master
|
||||||
|
[github-actions-ci-image]: https://badgen.net/github/checks/jshttp/accepts/master?label=ci
|
||||||
|
[github-actions-ci-url]: https://github.com/jshttp/accepts/actions/workflows/ci.yml
|
||||||
|
[node-version-image]: https://badgen.net/npm/node/accepts
|
||||||
|
[node-version-url]: https://nodejs.org/en/download
|
||||||
|
[npm-downloads-image]: https://badgen.net/npm/dm/accepts
|
||||||
|
[npm-url]: https://npmjs.org/package/accepts
|
||||||
|
[npm-version-image]: https://badgen.net/npm/v/accepts
|
||||||
238
node_modules/accepts/index.js
generated
vendored
Normal file
238
node_modules/accepts/index.js
generated
vendored
Normal file
@@ -0,0 +1,238 @@
|
|||||||
|
/*!
|
||||||
|
* accepts
|
||||||
|
* Copyright(c) 2014 Jonathan Ong
|
||||||
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
var Negotiator = require('negotiator')
|
||||||
|
var mime = require('mime-types')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = Accepts
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Accepts object for the given req.
|
||||||
|
*
|
||||||
|
* @param {object} req
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function Accepts (req) {
|
||||||
|
if (!(this instanceof Accepts)) {
|
||||||
|
return new Accepts(req)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.headers = req.headers
|
||||||
|
this.negotiator = new Negotiator(req)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the given `type(s)` is acceptable, returning
|
||||||
|
* the best match when true, otherwise `undefined`, in which
|
||||||
|
* case you should respond with 406 "Not Acceptable".
|
||||||
|
*
|
||||||
|
* The `type` value may be a single mime type string
|
||||||
|
* such as "application/json", the extension name
|
||||||
|
* such as "json" or an array `["json", "html", "text/plain"]`. When a list
|
||||||
|
* or array is given the _best_ match, if any is returned.
|
||||||
|
*
|
||||||
|
* Examples:
|
||||||
|
*
|
||||||
|
* // Accept: text/html
|
||||||
|
* this.types('html');
|
||||||
|
* // => "html"
|
||||||
|
*
|
||||||
|
* // Accept: text/*, application/json
|
||||||
|
* this.types('html');
|
||||||
|
* // => "html"
|
||||||
|
* this.types('text/html');
|
||||||
|
* // => "text/html"
|
||||||
|
* this.types('json', 'text');
|
||||||
|
* // => "json"
|
||||||
|
* this.types('application/json');
|
||||||
|
* // => "application/json"
|
||||||
|
*
|
||||||
|
* // Accept: text/*, application/json
|
||||||
|
* this.types('image/png');
|
||||||
|
* this.types('png');
|
||||||
|
* // => undefined
|
||||||
|
*
|
||||||
|
* // Accept: text/*;q=.5, application/json
|
||||||
|
* this.types(['html', 'json']);
|
||||||
|
* this.types('html', 'json');
|
||||||
|
* // => "json"
|
||||||
|
*
|
||||||
|
* @param {String|Array} types...
|
||||||
|
* @return {String|Array|Boolean}
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Accepts.prototype.type =
|
||||||
|
Accepts.prototype.types = function (types_) {
|
||||||
|
var types = types_
|
||||||
|
|
||||||
|
// support flattened arguments
|
||||||
|
if (types && !Array.isArray(types)) {
|
||||||
|
types = new Array(arguments.length)
|
||||||
|
for (var i = 0; i < types.length; i++) {
|
||||||
|
types[i] = arguments[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no types, return all requested types
|
||||||
|
if (!types || types.length === 0) {
|
||||||
|
return this.negotiator.mediaTypes()
|
||||||
|
}
|
||||||
|
|
||||||
|
// no accept header, return first given type
|
||||||
|
if (!this.headers.accept) {
|
||||||
|
return types[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
var mimes = types.map(extToMime)
|
||||||
|
var accepts = this.negotiator.mediaTypes(mimes.filter(validMime))
|
||||||
|
var first = accepts[0]
|
||||||
|
|
||||||
|
return first
|
||||||
|
? types[mimes.indexOf(first)]
|
||||||
|
: false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return accepted encodings or best fit based on `encodings`.
|
||||||
|
*
|
||||||
|
* Given `Accept-Encoding: gzip, deflate`
|
||||||
|
* an array sorted by quality is returned:
|
||||||
|
*
|
||||||
|
* ['gzip', 'deflate']
|
||||||
|
*
|
||||||
|
* @param {String|Array} encodings...
|
||||||
|
* @return {String|Array}
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Accepts.prototype.encoding =
|
||||||
|
Accepts.prototype.encodings = function (encodings_) {
|
||||||
|
var encodings = encodings_
|
||||||
|
|
||||||
|
// support flattened arguments
|
||||||
|
if (encodings && !Array.isArray(encodings)) {
|
||||||
|
encodings = new Array(arguments.length)
|
||||||
|
for (var i = 0; i < encodings.length; i++) {
|
||||||
|
encodings[i] = arguments[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no encodings, return all requested encodings
|
||||||
|
if (!encodings || encodings.length === 0) {
|
||||||
|
return this.negotiator.encodings()
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.negotiator.encodings(encodings)[0] || false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return accepted charsets or best fit based on `charsets`.
|
||||||
|
*
|
||||||
|
* Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
|
||||||
|
* an array sorted by quality is returned:
|
||||||
|
*
|
||||||
|
* ['utf-8', 'utf-7', 'iso-8859-1']
|
||||||
|
*
|
||||||
|
* @param {String|Array} charsets...
|
||||||
|
* @return {String|Array}
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Accepts.prototype.charset =
|
||||||
|
Accepts.prototype.charsets = function (charsets_) {
|
||||||
|
var charsets = charsets_
|
||||||
|
|
||||||
|
// support flattened arguments
|
||||||
|
if (charsets && !Array.isArray(charsets)) {
|
||||||
|
charsets = new Array(arguments.length)
|
||||||
|
for (var i = 0; i < charsets.length; i++) {
|
||||||
|
charsets[i] = arguments[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no charsets, return all requested charsets
|
||||||
|
if (!charsets || charsets.length === 0) {
|
||||||
|
return this.negotiator.charsets()
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.negotiator.charsets(charsets)[0] || false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return accepted languages or best fit based on `langs`.
|
||||||
|
*
|
||||||
|
* Given `Accept-Language: en;q=0.8, es, pt`
|
||||||
|
* an array sorted by quality is returned:
|
||||||
|
*
|
||||||
|
* ['es', 'pt', 'en']
|
||||||
|
*
|
||||||
|
* @param {String|Array} langs...
|
||||||
|
* @return {Array|String}
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Accepts.prototype.lang =
|
||||||
|
Accepts.prototype.langs =
|
||||||
|
Accepts.prototype.language =
|
||||||
|
Accepts.prototype.languages = function (languages_) {
|
||||||
|
var languages = languages_
|
||||||
|
|
||||||
|
// support flattened arguments
|
||||||
|
if (languages && !Array.isArray(languages)) {
|
||||||
|
languages = new Array(arguments.length)
|
||||||
|
for (var i = 0; i < languages.length; i++) {
|
||||||
|
languages[i] = arguments[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no languages, return all requested languages
|
||||||
|
if (!languages || languages.length === 0) {
|
||||||
|
return this.negotiator.languages()
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.negotiator.languages(languages)[0] || false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert extnames to mime.
|
||||||
|
*
|
||||||
|
* @param {String} type
|
||||||
|
* @return {String}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function extToMime (type) {
|
||||||
|
return type.indexOf('/') === -1
|
||||||
|
? mime.lookup(type)
|
||||||
|
: type
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if mime is valid.
|
||||||
|
*
|
||||||
|
* @param {String} type
|
||||||
|
* @return {String}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function validMime (type) {
|
||||||
|
return typeof type === 'string'
|
||||||
|
}
|
||||||
47
node_modules/accepts/package.json
generated
vendored
Normal file
47
node_modules/accepts/package.json
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"name": "accepts",
|
||||||
|
"description": "Higher-level content negotiation",
|
||||||
|
"version": "1.3.8",
|
||||||
|
"contributors": [
|
||||||
|
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||||
|
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "jshttp/accepts",
|
||||||
|
"dependencies": {
|
||||||
|
"mime-types": "~2.1.34",
|
||||||
|
"negotiator": "0.6.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"deep-equal": "1.0.1",
|
||||||
|
"eslint": "7.32.0",
|
||||||
|
"eslint-config-standard": "14.1.1",
|
||||||
|
"eslint-plugin-import": "2.25.4",
|
||||||
|
"eslint-plugin-markdown": "2.2.1",
|
||||||
|
"eslint-plugin-node": "11.1.0",
|
||||||
|
"eslint-plugin-promise": "4.3.1",
|
||||||
|
"eslint-plugin-standard": "4.1.0",
|
||||||
|
"mocha": "9.2.0",
|
||||||
|
"nyc": "15.1.0"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"LICENSE",
|
||||||
|
"HISTORY.md",
|
||||||
|
"index.js"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.6"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"lint": "eslint .",
|
||||||
|
"test": "mocha --reporter spec --check-leaks --bail test/",
|
||||||
|
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
||||||
|
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"content",
|
||||||
|
"negotiation",
|
||||||
|
"accept",
|
||||||
|
"accepts"
|
||||||
|
]
|
||||||
|
}
|
||||||
15
node_modules/anymatch/LICENSE
generated
vendored
Normal file
15
node_modules/anymatch/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
The ISC License
|
||||||
|
|
||||||
|
Copyright (c) 2019 Elan Shanker, Paul Miller (https://paulmillr.com)
|
||||||
|
|
||||||
|
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.
|
||||||
87
node_modules/anymatch/README.md
generated
vendored
Normal file
87
node_modules/anymatch/README.md
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
anymatch [](https://travis-ci.org/micromatch/anymatch) [](https://coveralls.io/r/micromatch/anymatch?branch=master)
|
||||||
|
======
|
||||||
|
Javascript module to match a string against a regular expression, glob, string,
|
||||||
|
or function that takes the string as an argument and returns a truthy or falsy
|
||||||
|
value. The matcher can also be an array of any or all of these. Useful for
|
||||||
|
allowing a very flexible user-defined config to define things like file paths.
|
||||||
|
|
||||||
|
__Note: This module has Bash-parity, please be aware that Windows-style backslashes are not supported as separators. See https://github.com/micromatch/micromatch#backslashes for more information.__
|
||||||
|
|
||||||
|
|
||||||
|
Usage
|
||||||
|
-----
|
||||||
|
```sh
|
||||||
|
npm install anymatch
|
||||||
|
```
|
||||||
|
|
||||||
|
#### anymatch(matchers, testString, [returnIndex], [options])
|
||||||
|
* __matchers__: (_Array|String|RegExp|Function_)
|
||||||
|
String to be directly matched, string with glob patterns, regular expression
|
||||||
|
test, function that takes the testString as an argument and returns a truthy
|
||||||
|
value if it should be matched, or an array of any number and mix of these types.
|
||||||
|
* __testString__: (_String|Array_) The string to test against the matchers. If
|
||||||
|
passed as an array, the first element of the array will be used as the
|
||||||
|
`testString` for non-function matchers, while the entire array will be applied
|
||||||
|
as the arguments for function matchers.
|
||||||
|
* __options__: (_Object_ [optional]_) Any of the [picomatch](https://github.com/micromatch/picomatch#options) options.
|
||||||
|
* __returnIndex__: (_Boolean [optional]_) If true, return the array index of
|
||||||
|
the first matcher that that testString matched, or -1 if no match, instead of a
|
||||||
|
boolean result.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const anymatch = require('anymatch');
|
||||||
|
|
||||||
|
const matchers = [ 'path/to/file.js', 'path/anyjs/**/*.js', /foo.js$/, string => string.includes('bar') && string.length > 10 ] ;
|
||||||
|
|
||||||
|
anymatch(matchers, 'path/to/file.js'); // true
|
||||||
|
anymatch(matchers, 'path/anyjs/baz.js'); // true
|
||||||
|
anymatch(matchers, 'path/to/foo.js'); // true
|
||||||
|
anymatch(matchers, 'path/to/bar.js'); // true
|
||||||
|
anymatch(matchers, 'bar.js'); // false
|
||||||
|
|
||||||
|
// returnIndex = true
|
||||||
|
anymatch(matchers, 'foo.js', {returnIndex: true}); // 2
|
||||||
|
anymatch(matchers, 'path/anyjs/foo.js', {returnIndex: true}); // 1
|
||||||
|
|
||||||
|
// any picomatc
|
||||||
|
|
||||||
|
// using globs to match directories and their children
|
||||||
|
anymatch('node_modules', 'node_modules'); // true
|
||||||
|
anymatch('node_modules', 'node_modules/somelib/index.js'); // false
|
||||||
|
anymatch('node_modules/**', 'node_modules/somelib/index.js'); // true
|
||||||
|
anymatch('node_modules/**', '/absolute/path/to/node_modules/somelib/index.js'); // false
|
||||||
|
anymatch('**/node_modules/**', '/absolute/path/to/node_modules/somelib/index.js'); // true
|
||||||
|
|
||||||
|
const matcher = anymatch(matchers);
|
||||||
|
['foo.js', 'bar.js'].filter(matcher); // [ 'foo.js' ]
|
||||||
|
anymatch master* ❯
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
#### anymatch(matchers)
|
||||||
|
You can also pass in only your matcher(s) to get a curried function that has
|
||||||
|
already been bound to the provided matching criteria. This can be used as an
|
||||||
|
`Array#filter` callback.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var matcher = anymatch(matchers);
|
||||||
|
|
||||||
|
matcher('path/to/file.js'); // true
|
||||||
|
matcher('path/anyjs/baz.js', true); // 1
|
||||||
|
|
||||||
|
['foo.js', 'bar.js'].filter(matcher); // ['foo.js']
|
||||||
|
```
|
||||||
|
|
||||||
|
Changelog
|
||||||
|
----------
|
||||||
|
[See release notes page on GitHub](https://github.com/micromatch/anymatch/releases)
|
||||||
|
|
||||||
|
- **v3.0:** Removed `startIndex` and `endIndex` arguments. Node 8.x-only.
|
||||||
|
- **v2.0:** [micromatch](https://github.com/jonschlinkert/micromatch) moves away from minimatch-parity and inline with Bash. This includes handling backslashes differently (see https://github.com/micromatch/micromatch#backslashes for more information).
|
||||||
|
- **v1.2:** anymatch uses [micromatch](https://github.com/jonschlinkert/micromatch)
|
||||||
|
for glob pattern matching. Issues with glob pattern matching should be
|
||||||
|
reported directly to the [micromatch issue tracker](https://github.com/jonschlinkert/micromatch/issues).
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
[ISC](https://raw.github.com/micromatch/anymatch/master/LICENSE)
|
||||||
20
node_modules/anymatch/index.d.ts
generated
vendored
Normal file
20
node_modules/anymatch/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
type AnymatchFn = (testString: string) => boolean;
|
||||||
|
type AnymatchPattern = string|RegExp|AnymatchFn;
|
||||||
|
type AnymatchMatcher = AnymatchPattern|AnymatchPattern[]
|
||||||
|
type AnymatchTester = {
|
||||||
|
(testString: string|any[], returnIndex: true): number;
|
||||||
|
(testString: string|any[]): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
type PicomatchOptions = {dot: boolean};
|
||||||
|
|
||||||
|
declare const anymatch: {
|
||||||
|
(matchers: AnymatchMatcher): AnymatchTester;
|
||||||
|
(matchers: AnymatchMatcher, testString: null, returnIndex: true | PicomatchOptions): AnymatchTester;
|
||||||
|
(matchers: AnymatchMatcher, testString: string|any[], returnIndex: true | PicomatchOptions): number;
|
||||||
|
(matchers: AnymatchMatcher, testString: string|any[]): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export {AnymatchMatcher as Matcher}
|
||||||
|
export {AnymatchTester as Tester}
|
||||||
|
export default anymatch
|
||||||
104
node_modules/anymatch/index.js
generated
vendored
Normal file
104
node_modules/anymatch/index.js
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
|
||||||
|
const picomatch = require('picomatch');
|
||||||
|
const normalizePath = require('normalize-path');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {(testString: string) => boolean} AnymatchFn
|
||||||
|
* @typedef {string|RegExp|AnymatchFn} AnymatchPattern
|
||||||
|
* @typedef {AnymatchPattern|AnymatchPattern[]} AnymatchMatcher
|
||||||
|
*/
|
||||||
|
const BANG = '!';
|
||||||
|
const DEFAULT_OPTIONS = {returnIndex: false};
|
||||||
|
const arrify = (item) => Array.isArray(item) ? item : [item];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {AnymatchPattern} matcher
|
||||||
|
* @param {object} options
|
||||||
|
* @returns {AnymatchFn}
|
||||||
|
*/
|
||||||
|
const createPattern = (matcher, options) => {
|
||||||
|
if (typeof matcher === 'function') {
|
||||||
|
return matcher;
|
||||||
|
}
|
||||||
|
if (typeof matcher === 'string') {
|
||||||
|
const glob = picomatch(matcher, options);
|
||||||
|
return (string) => matcher === string || glob(string);
|
||||||
|
}
|
||||||
|
if (matcher instanceof RegExp) {
|
||||||
|
return (string) => matcher.test(string);
|
||||||
|
}
|
||||||
|
return (string) => false;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Array<Function>} patterns
|
||||||
|
* @param {Array<Function>} negPatterns
|
||||||
|
* @param {String|Array} args
|
||||||
|
* @param {Boolean} returnIndex
|
||||||
|
* @returns {boolean|number}
|
||||||
|
*/
|
||||||
|
const matchPatterns = (patterns, negPatterns, args, returnIndex) => {
|
||||||
|
const isList = Array.isArray(args);
|
||||||
|
const _path = isList ? args[0] : args;
|
||||||
|
if (!isList && typeof _path !== 'string') {
|
||||||
|
throw new TypeError('anymatch: second argument must be a string: got ' +
|
||||||
|
Object.prototype.toString.call(_path))
|
||||||
|
}
|
||||||
|
const path = normalizePath(_path, false);
|
||||||
|
|
||||||
|
for (let index = 0; index < negPatterns.length; index++) {
|
||||||
|
const nglob = negPatterns[index];
|
||||||
|
if (nglob(path)) {
|
||||||
|
return returnIndex ? -1 : false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const applied = isList && [path].concat(args.slice(1));
|
||||||
|
for (let index = 0; index < patterns.length; index++) {
|
||||||
|
const pattern = patterns[index];
|
||||||
|
if (isList ? pattern(...applied) : pattern(path)) {
|
||||||
|
return returnIndex ? index : true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnIndex ? -1 : false;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {AnymatchMatcher} matchers
|
||||||
|
* @param {Array|string} testString
|
||||||
|
* @param {object} options
|
||||||
|
* @returns {boolean|number|Function}
|
||||||
|
*/
|
||||||
|
const anymatch = (matchers, testString, options = DEFAULT_OPTIONS) => {
|
||||||
|
if (matchers == null) {
|
||||||
|
throw new TypeError('anymatch: specify first argument');
|
||||||
|
}
|
||||||
|
const opts = typeof options === 'boolean' ? {returnIndex: options} : options;
|
||||||
|
const returnIndex = opts.returnIndex || false;
|
||||||
|
|
||||||
|
// Early cache for matchers.
|
||||||
|
const mtchers = arrify(matchers);
|
||||||
|
const negatedGlobs = mtchers
|
||||||
|
.filter(item => typeof item === 'string' && item.charAt(0) === BANG)
|
||||||
|
.map(item => item.slice(1))
|
||||||
|
.map(item => picomatch(item, opts));
|
||||||
|
const patterns = mtchers
|
||||||
|
.filter(item => typeof item !== 'string' || (typeof item === 'string' && item.charAt(0) !== BANG))
|
||||||
|
.map(matcher => createPattern(matcher, opts));
|
||||||
|
|
||||||
|
if (testString == null) {
|
||||||
|
return (testString, ri = false) => {
|
||||||
|
const returnIndex = typeof ri === 'boolean' ? ri : false;
|
||||||
|
return matchPatterns(patterns, negatedGlobs, testString, returnIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return matchPatterns(patterns, negatedGlobs, testString, returnIndex);
|
||||||
|
};
|
||||||
|
|
||||||
|
anymatch.default = anymatch;
|
||||||
|
module.exports = anymatch;
|
||||||
48
node_modules/anymatch/package.json
generated
vendored
Normal file
48
node_modules/anymatch/package.json
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
"name": "anymatch",
|
||||||
|
"version": "3.1.3",
|
||||||
|
"description": "Matches strings against configurable strings, globs, regular expressions, and/or functions",
|
||||||
|
"files": [
|
||||||
|
"index.js",
|
||||||
|
"index.d.ts"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"normalize-path": "^3.0.0",
|
||||||
|
"picomatch": "^2.0.4"
|
||||||
|
},
|
||||||
|
"author": {
|
||||||
|
"name": "Elan Shanker",
|
||||||
|
"url": "https://github.com/es128"
|
||||||
|
},
|
||||||
|
"license": "ISC",
|
||||||
|
"homepage": "https://github.com/micromatch/anymatch",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/micromatch/anymatch"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"match",
|
||||||
|
"any",
|
||||||
|
"string",
|
||||||
|
"file",
|
||||||
|
"fs",
|
||||||
|
"list",
|
||||||
|
"glob",
|
||||||
|
"regex",
|
||||||
|
"regexp",
|
||||||
|
"regular",
|
||||||
|
"expression",
|
||||||
|
"function"
|
||||||
|
],
|
||||||
|
"scripts": {
|
||||||
|
"test": "nyc mocha",
|
||||||
|
"mocha": "mocha"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"mocha": "^6.1.3",
|
||||||
|
"nyc": "^14.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 8"
|
||||||
|
}
|
||||||
|
}
|
||||||
21
node_modules/array-flatten/LICENSE
generated
vendored
Normal file
21
node_modules/array-flatten/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
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.
|
||||||
43
node_modules/array-flatten/README.md
generated
vendored
Normal file
43
node_modules/array-flatten/README.md
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
# Array Flatten
|
||||||
|
|
||||||
|
[![NPM version][npm-image]][npm-url]
|
||||||
|
[![NPM downloads][downloads-image]][downloads-url]
|
||||||
|
[![Build status][travis-image]][travis-url]
|
||||||
|
[![Test coverage][coveralls-image]][coveralls-url]
|
||||||
|
|
||||||
|
> Flatten an array of nested arrays into a single flat array. Accepts an optional depth.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install array-flatten --save
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var flatten = require('array-flatten')
|
||||||
|
|
||||||
|
flatten([1, [2, [3, [4, [5], 6], 7], 8], 9])
|
||||||
|
//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||||
|
|
||||||
|
flatten([1, [2, [3, [4, [5], 6], 7], 8], 9], 2)
|
||||||
|
//=> [1, 2, 3, [4, [5], 6], 7, 8, 9]
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
flatten(arguments) //=> [1, 2, 3]
|
||||||
|
})(1, [2, 3])
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT
|
||||||
|
|
||||||
|
[npm-image]: https://img.shields.io/npm/v/array-flatten.svg?style=flat
|
||||||
|
[npm-url]: https://npmjs.org/package/array-flatten
|
||||||
|
[downloads-image]: https://img.shields.io/npm/dm/array-flatten.svg?style=flat
|
||||||
|
[downloads-url]: https://npmjs.org/package/array-flatten
|
||||||
|
[travis-image]: https://img.shields.io/travis/blakeembrey/array-flatten.svg?style=flat
|
||||||
|
[travis-url]: https://travis-ci.org/blakeembrey/array-flatten
|
||||||
|
[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/array-flatten.svg?style=flat
|
||||||
|
[coveralls-url]: https://coveralls.io/r/blakeembrey/array-flatten?branch=master
|
||||||
64
node_modules/array-flatten/array-flatten.js
generated
vendored
Normal file
64
node_modules/array-flatten/array-flatten.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expose `arrayFlatten`.
|
||||||
|
*/
|
||||||
|
module.exports = arrayFlatten
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursive flatten function with depth.
|
||||||
|
*
|
||||||
|
* @param {Array} array
|
||||||
|
* @param {Array} result
|
||||||
|
* @param {Number} depth
|
||||||
|
* @return {Array}
|
||||||
|
*/
|
||||||
|
function flattenWithDepth (array, result, depth) {
|
||||||
|
for (var i = 0; i < array.length; i++) {
|
||||||
|
var value = array[i]
|
||||||
|
|
||||||
|
if (depth > 0 && Array.isArray(value)) {
|
||||||
|
flattenWithDepth(value, result, depth - 1)
|
||||||
|
} else {
|
||||||
|
result.push(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursive flatten function. Omitting depth is slightly faster.
|
||||||
|
*
|
||||||
|
* @param {Array} array
|
||||||
|
* @param {Array} result
|
||||||
|
* @return {Array}
|
||||||
|
*/
|
||||||
|
function flattenForever (array, result) {
|
||||||
|
for (var i = 0; i < array.length; i++) {
|
||||||
|
var value = array[i]
|
||||||
|
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
flattenForever(value, result)
|
||||||
|
} else {
|
||||||
|
result.push(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flatten an array, with the ability to define a depth.
|
||||||
|
*
|
||||||
|
* @param {Array} array
|
||||||
|
* @param {Number} depth
|
||||||
|
* @return {Array}
|
||||||
|
*/
|
||||||
|
function arrayFlatten (array, depth) {
|
||||||
|
if (depth == null) {
|
||||||
|
return flattenForever(array, [])
|
||||||
|
}
|
||||||
|
|
||||||
|
return flattenWithDepth(array, [], depth)
|
||||||
|
}
|
||||||
39
node_modules/array-flatten/package.json
generated
vendored
Normal file
39
node_modules/array-flatten/package.json
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"name": "array-flatten",
|
||||||
|
"version": "1.1.1",
|
||||||
|
"description": "Flatten an array of nested arrays into a single flat array",
|
||||||
|
"main": "array-flatten.js",
|
||||||
|
"files": [
|
||||||
|
"array-flatten.js",
|
||||||
|
"LICENSE"
|
||||||
|
],
|
||||||
|
"scripts": {
|
||||||
|
"test": "istanbul cover _mocha -- -R spec"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/blakeembrey/array-flatten.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"array",
|
||||||
|
"flatten",
|
||||||
|
"arguments",
|
||||||
|
"depth"
|
||||||
|
],
|
||||||
|
"author": {
|
||||||
|
"name": "Blake Embrey",
|
||||||
|
"email": "hello@blakeembrey.com",
|
||||||
|
"url": "http://blakeembrey.me"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/blakeembrey/array-flatten/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/blakeembrey/array-flatten",
|
||||||
|
"devDependencies": {
|
||||||
|
"istanbul": "^0.3.13",
|
||||||
|
"mocha": "^2.2.4",
|
||||||
|
"pre-commit": "^1.0.7",
|
||||||
|
"standard": "^3.7.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
19
node_modules/aws-ssl-profiles/LICENSE
generated
vendored
Normal file
19
node_modules/aws-ssl-profiles/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
Copyright (c) 2024 Andrey Sidorov, Douglas Wilson, Weslley Araújo and contributors.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
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.
|
||||||
146
node_modules/aws-ssl-profiles/README.md
generated
vendored
Normal file
146
node_modules/aws-ssl-profiles/README.md
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
# AWS SSL Profiles
|
||||||
|
|
||||||
|
[**AWS RDS**](https://aws.amazon.com/rds/) **SSL** Certificates Bundles.
|
||||||
|
|
||||||
|
**Table of Contents**
|
||||||
|
|
||||||
|
- [Installation](#installation)
|
||||||
|
- [Usage](#usage)
|
||||||
|
- [**mysqljs/mysql**](#mysqljsmysql)
|
||||||
|
- [**MySQL2**](#mysql2)
|
||||||
|
- [**node-postgres**](#node-postgres)
|
||||||
|
- [Custom `ssl` options](#custom-ssl-options)
|
||||||
|
- [License](#license)
|
||||||
|
- [Security](#security)
|
||||||
|
- [Contributing](#contributing)
|
||||||
|
- [Acknowledgements](#acknowledgements)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install --save aws-ssl-profiles
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### [mysqljs/mysql](https://github.com/mysqljs/mysql)
|
||||||
|
|
||||||
|
```js
|
||||||
|
const mysql = require('mysql');
|
||||||
|
const awsCaBundle = require('aws-ssl-profiles');
|
||||||
|
|
||||||
|
// mysql connection
|
||||||
|
const connection = mysql.createConnection({
|
||||||
|
//...
|
||||||
|
ssl: awsCaBundle,
|
||||||
|
});
|
||||||
|
|
||||||
|
// mysql connection pool
|
||||||
|
const pool = mysql.createPool({
|
||||||
|
//...
|
||||||
|
ssl: awsCaBundle,
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### [MySQL2](https://github.com/sidorares/node-mysql2)
|
||||||
|
|
||||||
|
```js
|
||||||
|
const mysql = require('mysql2');
|
||||||
|
const awsCaBundle = require('aws-ssl-profiles');
|
||||||
|
|
||||||
|
// mysql2 connection
|
||||||
|
const connection = mysql.createConnection({
|
||||||
|
//...
|
||||||
|
ssl: awsCaBundle,
|
||||||
|
});
|
||||||
|
|
||||||
|
// mysql2 connection pool
|
||||||
|
const pool = mysql.createPool({
|
||||||
|
//...
|
||||||
|
ssl: awsCaBundle,
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### [node-postgres](https://github.com/brianc/node-postgres)
|
||||||
|
|
||||||
|
```js
|
||||||
|
const pg = require('pg');
|
||||||
|
const awsCaBundle = require('aws-ssl-profiles');
|
||||||
|
|
||||||
|
// pg connection
|
||||||
|
const client = new pg.Client({
|
||||||
|
// ...
|
||||||
|
ssl: awsCaBundle,
|
||||||
|
});
|
||||||
|
|
||||||
|
// pg connection pool
|
||||||
|
const pool = new pg.Pool({
|
||||||
|
// ...
|
||||||
|
ssl: awsCaBundle,
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Custom `ssl` options
|
||||||
|
|
||||||
|
Using **AWS SSL Profiles** with custom `ssl` options:
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
ssl: {
|
||||||
|
...awsCaBundle,
|
||||||
|
rejectUnauthorized: true,
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
ssl: {
|
||||||
|
ca: awsCaBundle.ca,
|
||||||
|
rejectUnauthorized: true,
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Custom bundles
|
||||||
|
|
||||||
|
```js
|
||||||
|
const { proxyBundle } = require('aws-ssl-profiles');
|
||||||
|
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
ssl: proxyBundle,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
**AWS SSL Profiles** is under the [**MIT License**](./LICENSE).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Security
|
||||||
|
|
||||||
|
Please check the [**SECURITY.md**](./SECURITY.md).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Please check the [**CONTRIBUTING.md**](./CONTRIBUTING.md) for instructions.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Acknowledgements
|
||||||
|
|
||||||
|
[**Contributors**](https://github.com/mysqljs/aws-ssl-profiles/graphs/contributors).
|
||||||
4
node_modules/aws-ssl-profiles/lib/@types/profiles.d.ts
generated
vendored
Normal file
4
node_modules/aws-ssl-profiles/lib/@types/profiles.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export type CA = string[];
|
||||||
|
export type Profiles = {
|
||||||
|
ca: CA;
|
||||||
|
};
|
||||||
2
node_modules/aws-ssl-profiles/lib/@types/profiles.js
generated
vendored
Normal file
2
node_modules/aws-ssl-profiles/lib/@types/profiles.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
8
node_modules/aws-ssl-profiles/lib/index.d.ts
generated
vendored
Normal file
8
node_modules/aws-ssl-profiles/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import type { Profiles } from "./@types/profiles.js";
|
||||||
|
export declare const proxyBundle: Profiles;
|
||||||
|
declare const profiles: Profiles;
|
||||||
|
declare module "aws-ssl-profiles" {
|
||||||
|
const profiles: Profiles & { proxyBundle: Profiles };
|
||||||
|
export = profiles;
|
||||||
|
}
|
||||||
|
export default profiles;
|
||||||
13
node_modules/aws-ssl-profiles/lib/index.js
generated
vendored
Normal file
13
node_modules/aws-ssl-profiles/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const defaults_js_1 = require("./profiles/ca/defaults.js");
|
||||||
|
const proxies_js_1 = require("./profiles/ca/proxies.js");
|
||||||
|
const proxyBundle = {
|
||||||
|
ca: proxies_js_1.proxies,
|
||||||
|
};
|
||||||
|
const profiles = {
|
||||||
|
ca: [...defaults_js_1.defaults, ...proxies_js_1.proxies],
|
||||||
|
};
|
||||||
|
module.exports = profiles;
|
||||||
|
module.exports.proxyBundle = proxyBundle;
|
||||||
|
module.exports.default = profiles;
|
||||||
9
node_modules/aws-ssl-profiles/lib/profiles/ca/defaults.d.ts
generated
vendored
Normal file
9
node_modules/aws-ssl-profiles/lib/profiles/ca/defaults.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import type { CA } from '../../@types/profiles.js';
|
||||||
|
/**
|
||||||
|
* CA Certificates for **Amazon RDS** (2024)
|
||||||
|
*
|
||||||
|
* - https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html
|
||||||
|
* - https://docs.amazonaws.cn/en_us/AmazonRDS/latest/AuroraUserGuide/UsingWithRDS.SSL.html
|
||||||
|
* - https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless.html#aurora-serverless.tls
|
||||||
|
*/
|
||||||
|
export declare const defaults: CA;
|
||||||
2888
node_modules/aws-ssl-profiles/lib/profiles/ca/defaults.js
generated
vendored
Normal file
2888
node_modules/aws-ssl-profiles/lib/profiles/ca/defaults.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8
node_modules/aws-ssl-profiles/lib/profiles/ca/proxies.d.ts
generated
vendored
Normal file
8
node_modules/aws-ssl-profiles/lib/profiles/ca/proxies.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import type { CA } from '../../@types/profiles.js';
|
||||||
|
/**
|
||||||
|
* CA Certificates for **Amazon RDS Proxy** (2024)
|
||||||
|
*
|
||||||
|
* - https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-proxy.howitworks.html#rds-proxy-security.tls
|
||||||
|
* - https://www.amazontrust.com/repository/
|
||||||
|
*/
|
||||||
|
export declare const proxies: CA;
|
||||||
111
node_modules/aws-ssl-profiles/lib/profiles/ca/proxies.js
generated
vendored
Normal file
111
node_modules/aws-ssl-profiles/lib/profiles/ca/proxies.js
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.proxies = void 0;
|
||||||
|
/**
|
||||||
|
* CA Certificates for **Amazon RDS Proxy** (2024)
|
||||||
|
*
|
||||||
|
* - https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-proxy.howitworks.html#rds-proxy-security.tls
|
||||||
|
* - https://www.amazontrust.com/repository/
|
||||||
|
*/
|
||||||
|
exports.proxies = [
|
||||||
|
'-----BEGIN CERTIFICATE-----\n' +
|
||||||
|
'MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF\n' +
|
||||||
|
'ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n' +
|
||||||
|
'b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL\n' +
|
||||||
|
'MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n' +
|
||||||
|
'b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj\n' +
|
||||||
|
'ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM\n' +
|
||||||
|
'9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw\n' +
|
||||||
|
'IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6\n' +
|
||||||
|
'VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L\n' +
|
||||||
|
'93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm\n' +
|
||||||
|
'jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC\n' +
|
||||||
|
'AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA\n' +
|
||||||
|
'A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI\n' +
|
||||||
|
'U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs\n' +
|
||||||
|
'N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv\n' +
|
||||||
|
'o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU\n' +
|
||||||
|
'5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy\n' +
|
||||||
|
'rqXRfboQnoZsG4q5WTP468SQvvG5\n' +
|
||||||
|
'-----END CERTIFICATE-----\n',
|
||||||
|
'-----BEGIN CERTIFICATE-----\n' +
|
||||||
|
'MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwF\n' +
|
||||||
|
'ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n' +
|
||||||
|
'b24gUm9vdCBDQSAyMB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTEL\n' +
|
||||||
|
'MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n' +
|
||||||
|
'b3QgQ0EgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK2Wny2cSkxK\n' +
|
||||||
|
'gXlRmeyKy2tgURO8TW0G/LAIjd0ZEGrHJgw12MBvIITplLGbhQPDW9tK6Mj4kHbZ\n' +
|
||||||
|
'W0/jTOgGNk3Mmqw9DJArktQGGWCsN0R5hYGCrVo34A3MnaZMUnbqQ523BNFQ9lXg\n' +
|
||||||
|
'1dKmSYXpN+nKfq5clU1Imj+uIFptiJXZNLhSGkOQsL9sBbm2eLfq0OQ6PBJTYv9K\n' +
|
||||||
|
'8nu+NQWpEjTj82R0Yiw9AElaKP4yRLuH3WUnAnE72kr3H9rN9yFVkE8P7K6C4Z9r\n' +
|
||||||
|
'2UXTu/Bfh+08LDmG2j/e7HJV63mjrdvdfLC6HM783k81ds8P+HgfajZRRidhW+me\n' +
|
||||||
|
'z/CiVX18JYpvL7TFz4QuK/0NURBs+18bvBt+xa47mAExkv8LV/SasrlX6avvDXbR\n' +
|
||||||
|
'8O70zoan4G7ptGmh32n2M8ZpLpcTnqWHsFcQgTfJU7O7f/aS0ZzQGPSSbtqDT6Zj\n' +
|
||||||
|
'mUyl+17vIWR6IF9sZIUVyzfpYgwLKhbcAS4y2j5L9Z469hdAlO+ekQiG+r5jqFoz\n' +
|
||||||
|
'7Mt0Q5X5bGlSNscpb/xVA1wf+5+9R+vnSUeVC06JIglJ4PVhHvG/LopyboBZ/1c6\n' +
|
||||||
|
'+XUyo05f7O0oYtlNc/LMgRdg7c3r3NunysV+Ar3yVAhU/bQtCSwXVEqY0VThUWcI\n' +
|
||||||
|
'0u1ufm8/0i2BWSlmy5A5lREedCf+3euvAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMB\n' +
|
||||||
|
'Af8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSwDPBMMPQFWAJI/TPlUq9LhONm\n' +
|
||||||
|
'UjANBgkqhkiG9w0BAQwFAAOCAgEAqqiAjw54o+Ci1M3m9Zh6O+oAA7CXDpO8Wqj2\n' +
|
||||||
|
'LIxyh6mx/H9z/WNxeKWHWc8w4Q0QshNabYL1auaAn6AFC2jkR2vHat+2/XcycuUY\n' +
|
||||||
|
'+gn0oJMsXdKMdYV2ZZAMA3m3MSNjrXiDCYZohMr/+c8mmpJ5581LxedhpxfL86kS\n' +
|
||||||
|
'k5Nrp+gvU5LEYFiwzAJRGFuFjWJZY7attN6a+yb3ACfAXVU3dJnJUH/jWS5E4ywl\n' +
|
||||||
|
'7uxMMne0nxrpS10gxdr9HIcWxkPo1LsmmkVwXqkLN1PiRnsn/eBG8om3zEK2yygm\n' +
|
||||||
|
'btmlyTrIQRNg91CMFa6ybRoVGld45pIq2WWQgj9sAq+uEjonljYE1x2igGOpm/Hl\n' +
|
||||||
|
'urR8FLBOybEfdF849lHqm/osohHUqS0nGkWxr7JOcQ3AWEbWaQbLU8uz/mtBzUF+\n' +
|
||||||
|
'fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoVYh63\n' +
|
||||||
|
'n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE\n' +
|
||||||
|
'76KlXIx3KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H\n' +
|
||||||
|
'9jVlpNMKVv/1F2Rs76giJUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT\n' +
|
||||||
|
'4PsJYGw=\n' +
|
||||||
|
'-----END CERTIFICATE-----\n',
|
||||||
|
'-----BEGIN CERTIFICATE-----\n' +
|
||||||
|
'MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5\n' +
|
||||||
|
'MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n' +
|
||||||
|
'Um9vdCBDQSAzMB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG\n' +
|
||||||
|
'A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg\n' +
|
||||||
|
'Q0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZBf8ANm+gBG1bG8lKl\n' +
|
||||||
|
'ui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjrZt6j\n' +
|
||||||
|
'QjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSr\n' +
|
||||||
|
'ttvXBp43rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkr\n' +
|
||||||
|
'BqWTrBqYaGFy+uGh0PsceGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteM\n' +
|
||||||
|
'YyRIHN8wfdVoOw==\n' +
|
||||||
|
'-----END CERTIFICATE-----\n',
|
||||||
|
'-----BEGIN CERTIFICATE-----\n' +
|
||||||
|
'MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5\n' +
|
||||||
|
'MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n' +
|
||||||
|
'Um9vdCBDQSA0MB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG\n' +
|
||||||
|
'A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg\n' +
|
||||||
|
'Q0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN/sGKe0uoe0ZLY7Bi\n' +
|
||||||
|
'9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri83Bk\n' +
|
||||||
|
'M6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB\n' +
|
||||||
|
'/zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WB\n' +
|
||||||
|
'MAoGCCqGSM49BAMDA2gAMGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlw\n' +
|
||||||
|
'CkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1AE47xDqUEpHJWEadIRNyp4iciuRMStuW\n' +
|
||||||
|
'1KyLa2tJElMzrdfkviT8tQp21KW8EA==\n' +
|
||||||
|
'-----END CERTIFICATE-----\n',
|
||||||
|
'-----BEGIN CERTIFICATE-----\n' +
|
||||||
|
'MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMx\n' +
|
||||||
|
'EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n' +
|
||||||
|
'HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVs\n' +
|
||||||
|
'ZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5\n' +
|
||||||
|
'MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNVBAYTAlVTMRAwDgYD\n' +
|
||||||
|
'VQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFy\n' +
|
||||||
|
'ZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2Vy\n' +
|
||||||
|
'dmljZXMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZI\n' +
|
||||||
|
'hvcNAQEBBQADggEPADCCAQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20p\n' +
|
||||||
|
'OsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm2\n' +
|
||||||
|
'8xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4PahHQUw2eeBGg6345AWh1K\n' +
|
||||||
|
'Ts9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLPLJGmpufe\n' +
|
||||||
|
'hRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk\n' +
|
||||||
|
'6mFBrMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAw\n' +
|
||||||
|
'DwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+q\n' +
|
||||||
|
'AdcwKziIorhtSpzyEZGDMA0GCSqGSIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMI\n' +
|
||||||
|
'bw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPPE95Dz+I0swSdHynVv/heyNXB\n' +
|
||||||
|
've6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTyxQGjhdByPq1z\n' +
|
||||||
|
'qwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd\n' +
|
||||||
|
'iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn\n' +
|
||||||
|
'0q23KXB56jzaYyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCN\n' +
|
||||||
|
'sSi6\n' +
|
||||||
|
'-----END CERTIFICATE-----\n',
|
||||||
|
];
|
||||||
52
node_modules/aws-ssl-profiles/package.json
generated
vendored
Normal file
52
node_modules/aws-ssl-profiles/package.json
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
{
|
||||||
|
"name": "aws-ssl-profiles",
|
||||||
|
"version": "1.1.2",
|
||||||
|
"main": "lib/index.js",
|
||||||
|
"author": "https://github.com/wellwelwel",
|
||||||
|
"description": "AWS RDS SSL certificates bundles.",
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/mysqljs/aws-ssl-profiles"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/mysqljs/aws-ssl-profiles/issues"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@biomejs/biome": "^1.8.3",
|
||||||
|
"@types/node": "^22.5.1",
|
||||||
|
"@types/x509.js": "^1.0.3",
|
||||||
|
"poku": "^2.5.0",
|
||||||
|
"prettier": "^3.3.3",
|
||||||
|
"tsx": "^4.19.0",
|
||||||
|
"typescript": "^5.5.4",
|
||||||
|
"x509.js": "^1.0.0"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"lib"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 6.0.0"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"mysql",
|
||||||
|
"mysql2",
|
||||||
|
"pg",
|
||||||
|
"postgres",
|
||||||
|
"aws",
|
||||||
|
"rds",
|
||||||
|
"ssl",
|
||||||
|
"certificates",
|
||||||
|
"ca",
|
||||||
|
"bundle"
|
||||||
|
],
|
||||||
|
"scripts": {
|
||||||
|
"build": "npx tsc",
|
||||||
|
"postbuild": "cp src/index.d.ts lib/index.d.ts",
|
||||||
|
"lint": "npx @biomejs/biome lint && prettier --check .",
|
||||||
|
"lint:fix": "npx @biomejs/biome lint --write . && prettier --write .",
|
||||||
|
"pretest": "npm run build",
|
||||||
|
"test": "poku --parallel ./test",
|
||||||
|
"test:ci": "npm run lint && npm run test"
|
||||||
|
}
|
||||||
|
}
|
||||||
2
node_modules/balanced-match/.github/FUNDING.yml
generated
vendored
Normal file
2
node_modules/balanced-match/.github/FUNDING.yml
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
tidelift: "npm/balanced-match"
|
||||||
|
patreon: juliangruber
|
||||||
21
node_modules/balanced-match/LICENSE.md
generated
vendored
Normal file
21
node_modules/balanced-match/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
(MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
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.
|
||||||
97
node_modules/balanced-match/README.md
generated
vendored
Normal file
97
node_modules/balanced-match/README.md
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
# balanced-match
|
||||||
|
|
||||||
|
Match balanced string pairs, like `{` and `}` or `<b>` and `</b>`. Supports regular expressions as well!
|
||||||
|
|
||||||
|
[](http://travis-ci.org/juliangruber/balanced-match)
|
||||||
|
[](https://www.npmjs.org/package/balanced-match)
|
||||||
|
|
||||||
|
[](https://ci.testling.com/juliangruber/balanced-match)
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
Get the first matching pair of braces:
|
||||||
|
|
||||||
|
```js
|
||||||
|
var balanced = require('balanced-match');
|
||||||
|
|
||||||
|
console.log(balanced('{', '}', 'pre{in{nested}}post'));
|
||||||
|
console.log(balanced('{', '}', 'pre{first}between{second}post'));
|
||||||
|
console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post'));
|
||||||
|
```
|
||||||
|
|
||||||
|
The matches are:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ node example.js
|
||||||
|
{ start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' }
|
||||||
|
{ start: 3,
|
||||||
|
end: 9,
|
||||||
|
pre: 'pre',
|
||||||
|
body: 'first',
|
||||||
|
post: 'between{second}post' }
|
||||||
|
{ start: 3, end: 17, pre: 'pre', body: 'in{nest}', post: 'post' }
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
### var m = balanced(a, b, str)
|
||||||
|
|
||||||
|
For the first non-nested matching pair of `a` and `b` in `str`, return an
|
||||||
|
object with those keys:
|
||||||
|
|
||||||
|
* **start** the index of the first match of `a`
|
||||||
|
* **end** the index of the matching `b`
|
||||||
|
* **pre** the preamble, `a` and `b` not included
|
||||||
|
* **body** the match, `a` and `b` not included
|
||||||
|
* **post** the postscript, `a` and `b` not included
|
||||||
|
|
||||||
|
If there's no match, `undefined` will be returned.
|
||||||
|
|
||||||
|
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `['{', 'a', '']` and `{a}}` will match `['', 'a', '}']`.
|
||||||
|
|
||||||
|
### var r = balanced.range(a, b, str)
|
||||||
|
|
||||||
|
For the first non-nested matching pair of `a` and `b` in `str`, return an
|
||||||
|
array with indexes: `[ <a index>, <b index> ]`.
|
||||||
|
|
||||||
|
If there's no match, `undefined` will be returned.
|
||||||
|
|
||||||
|
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `[ 1, 3 ]` and `{a}}` will match `[0, 2]`.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
With [npm](https://npmjs.org) do:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install balanced-match
|
||||||
|
```
|
||||||
|
|
||||||
|
## Security contact information
|
||||||
|
|
||||||
|
To report a security vulnerability, please use the
|
||||||
|
[Tidelift security contact](https://tidelift.com/security).
|
||||||
|
Tidelift will coordinate the fix and disclosure.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
(MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
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.
|
||||||
62
node_modules/balanced-match/index.js
generated
vendored
Normal file
62
node_modules/balanced-match/index.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
'use strict';
|
||||||
|
module.exports = balanced;
|
||||||
|
function balanced(a, b, str) {
|
||||||
|
if (a instanceof RegExp) a = maybeMatch(a, str);
|
||||||
|
if (b instanceof RegExp) b = maybeMatch(b, str);
|
||||||
|
|
||||||
|
var r = range(a, b, str);
|
||||||
|
|
||||||
|
return r && {
|
||||||
|
start: r[0],
|
||||||
|
end: r[1],
|
||||||
|
pre: str.slice(0, r[0]),
|
||||||
|
body: str.slice(r[0] + a.length, r[1]),
|
||||||
|
post: str.slice(r[1] + b.length)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function maybeMatch(reg, str) {
|
||||||
|
var m = str.match(reg);
|
||||||
|
return m ? m[0] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
balanced.range = range;
|
||||||
|
function range(a, b, str) {
|
||||||
|
var begs, beg, left, right, result;
|
||||||
|
var ai = str.indexOf(a);
|
||||||
|
var bi = str.indexOf(b, ai + 1);
|
||||||
|
var i = ai;
|
||||||
|
|
||||||
|
if (ai >= 0 && bi > 0) {
|
||||||
|
if(a===b) {
|
||||||
|
return [ai, bi];
|
||||||
|
}
|
||||||
|
begs = [];
|
||||||
|
left = str.length;
|
||||||
|
|
||||||
|
while (i >= 0 && !result) {
|
||||||
|
if (i == ai) {
|
||||||
|
begs.push(i);
|
||||||
|
ai = str.indexOf(a, i + 1);
|
||||||
|
} else if (begs.length == 1) {
|
||||||
|
result = [ begs.pop(), bi ];
|
||||||
|
} else {
|
||||||
|
beg = begs.pop();
|
||||||
|
if (beg < left) {
|
||||||
|
left = beg;
|
||||||
|
right = bi;
|
||||||
|
}
|
||||||
|
|
||||||
|
bi = str.indexOf(b, i + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
i = ai < bi && ai >= 0 ? ai : bi;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (begs.length) {
|
||||||
|
result = [ left, right ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
48
node_modules/balanced-match/package.json
generated
vendored
Normal file
48
node_modules/balanced-match/package.json
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
"name": "balanced-match",
|
||||||
|
"description": "Match balanced character pairs, like \"{\" and \"}\"",
|
||||||
|
"version": "1.0.2",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/juliangruber/balanced-match.git"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/juliangruber/balanced-match",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "tape test/test.js",
|
||||||
|
"bench": "matcha test/bench.js"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"matcha": "^0.7.0",
|
||||||
|
"tape": "^4.6.0"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"match",
|
||||||
|
"regexp",
|
||||||
|
"test",
|
||||||
|
"balanced",
|
||||||
|
"parse"
|
||||||
|
],
|
||||||
|
"author": {
|
||||||
|
"name": "Julian Gruber",
|
||||||
|
"email": "mail@juliangruber.com",
|
||||||
|
"url": "http://juliangruber.com"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"testling": {
|
||||||
|
"files": "test/*.js",
|
||||||
|
"browsers": [
|
||||||
|
"ie/8..latest",
|
||||||
|
"firefox/20..latest",
|
||||||
|
"firefox/nightly",
|
||||||
|
"chrome/25..latest",
|
||||||
|
"chrome/canary",
|
||||||
|
"opera/12..latest",
|
||||||
|
"opera/next",
|
||||||
|
"safari/5.1..latest",
|
||||||
|
"ipad/6.0..latest",
|
||||||
|
"iphone/6.0..latest",
|
||||||
|
"android-browser/4.2..latest"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
266
node_modules/bignumber.js/CHANGELOG.md
generated
vendored
Normal file
266
node_modules/bignumber.js/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,266 @@
|
|||||||
|
#### 9.0.0
|
||||||
|
* 27/05/2019
|
||||||
|
* For compatibility with legacy browsers, remove `Symbol` references.
|
||||||
|
|
||||||
|
#### 8.1.1
|
||||||
|
* 24/02/2019
|
||||||
|
* [BUGFIX] #222 Restore missing `var` to `export BigNumber`.
|
||||||
|
* Allow any key in BigNumber.Instance in *bignumber.d.ts*.
|
||||||
|
|
||||||
|
#### 8.1.0
|
||||||
|
* 23/02/2019
|
||||||
|
* [NEW FEATURE] #220 Create a BigNumber using `{s, e, c}`.
|
||||||
|
* [NEW FEATURE] `isBigNumber`: if `BigNumber.DEBUG` is `true`, also check that the BigNumber instance is well-formed.
|
||||||
|
* Remove `instanceof` checks; just use `_isBigNumber` to identify a BigNumber instance.
|
||||||
|
* Add `_isBigNumber` to prototype in *bignumber.mjs*.
|
||||||
|
* Add tests for BigNumber creation from object.
|
||||||
|
* Update *API.html*.
|
||||||
|
|
||||||
|
#### 8.0.2
|
||||||
|
* 13/01/2019
|
||||||
|
* #209 `toPrecision` without argument should follow `toString`.
|
||||||
|
* Improve *Use* section of *README*.
|
||||||
|
* Optimise `toString(10)`.
|
||||||
|
* Add verson number to API doc.
|
||||||
|
|
||||||
|
#### 8.0.1
|
||||||
|
* 01/11/2018
|
||||||
|
* Rest parameter must be array type in *bignumber.d.ts*.
|
||||||
|
|
||||||
|
#### 8.0.0
|
||||||
|
* 01/11/2018
|
||||||
|
* [NEW FEATURE] Add `BigNumber.sum` method.
|
||||||
|
* [NEW FEATURE]`toFormat`: add `prefix` and `suffix` options.
|
||||||
|
* [NEW FEATURE] #178 Pass custom formatting to `toFormat`.
|
||||||
|
* [BREAKING CHANGE] #184 `toFraction`: return array of BigNumbers not strings.
|
||||||
|
* [NEW FEATURE] #185 Enable overwrite of `valueOf` to prevent accidental addition to string.
|
||||||
|
* #183 Add Node.js `crypto` requirement to documentation.
|
||||||
|
* [BREAKING CHANGE] #198 Disallow signs and whitespace in custom alphabet.
|
||||||
|
* [NEW FEATURE] #188 Implement `util.inspect.custom` for Node.js REPL.
|
||||||
|
* #170 Make `isBigNumber` a type guard in *bignumber.d.ts*.
|
||||||
|
* [BREAKING CHANGE] `BigNumber.min` and `BigNumber.max`: don't accept an array.
|
||||||
|
* Update *.travis.yml*.
|
||||||
|
* Remove *bower.json*.
|
||||||
|
|
||||||
|
#### 7.2.1
|
||||||
|
* 24/05/2018
|
||||||
|
* Add `browser` field to *package.json*.
|
||||||
|
|
||||||
|
#### 7.2.0
|
||||||
|
* 22/05/2018
|
||||||
|
* #166 Correct *.mjs* file. Remove extension from `main` field in *package.json*.
|
||||||
|
|
||||||
|
#### 7.1.0
|
||||||
|
* 18/05/2018
|
||||||
|
* Add `module` field to *package.json* for *bignumber.mjs*.
|
||||||
|
|
||||||
|
#### 7.0.2
|
||||||
|
* 17/05/2018
|
||||||
|
* #165 Bugfix: upper-case letters for bases 11-36 in a custom alphabet.
|
||||||
|
* Add note to *README* regarding creating BigNumbers from Number values.
|
||||||
|
|
||||||
|
#### 7.0.1
|
||||||
|
* 26/04/2018
|
||||||
|
* #158 Fix global object variable name typo.
|
||||||
|
|
||||||
|
#### 7.0.0
|
||||||
|
* 26/04/2018
|
||||||
|
* #143 Remove global BigNumber from typings.
|
||||||
|
* #144 Enable compatibility with `Object.freeze(Object.prototype)`.
|
||||||
|
* #148 #123 #11 Only throw on a number primitive with more than 15 significant digits if `BigNumber.DEBUG` is `true`.
|
||||||
|
* Only throw on an invalid BigNumber value if `BigNumber.DEBUG` is `true`. Return BigNumber `NaN` instead.
|
||||||
|
* #154 `exponentiatedBy`: allow BigNumber exponent.
|
||||||
|
* #156 Prevent Content Security Policy *unsafe-eval* issue.
|
||||||
|
* `toFraction`: allow `Infinity` maximum denominator.
|
||||||
|
* Comment-out some excess tests to reduce test time.
|
||||||
|
* Amend indentation and other spacing.
|
||||||
|
|
||||||
|
#### 6.0.0
|
||||||
|
* 26/01/2018
|
||||||
|
* #137 Implement `APLHABET` configuration option.
|
||||||
|
* Remove `ERRORS` configuration option.
|
||||||
|
* Remove `toDigits` method; extend `precision` method accordingly.
|
||||||
|
* Remove s`round` method; extend `decimalPlaces` method accordingly.
|
||||||
|
* Remove methods: `ceil`, `floor`, and `truncated`.
|
||||||
|
* Remove method aliases: `add`, `cmp`, `isInt`, `isNeg`, `trunc`, `mul`, `neg` and `sub`.
|
||||||
|
* Rename methods: `shift` to `shiftedBy`, `another` to `clone`, `toPower` to `exponentiatedBy`, and `equals` to `isEqualTo`.
|
||||||
|
* Rename methods: add `is` prefix to `greaterThan`, `greaterThanOrEqualTo`, `lessThan` and `lessThanOrEqualTo`.
|
||||||
|
* Add methods: `multipliedBy`, `isBigNumber`, `isPositive`, `integerValue`, `maximum` and `minimum`.
|
||||||
|
* Refactor test suite.
|
||||||
|
* Add *CHANGELOG.md*.
|
||||||
|
* Rewrite *bignumber.d.ts*.
|
||||||
|
* Redo API image.
|
||||||
|
|
||||||
|
#### 5.0.0
|
||||||
|
* 27/11/2017
|
||||||
|
* #81 Don't throw on constructor call without `new`.
|
||||||
|
|
||||||
|
#### 4.1.0
|
||||||
|
* 26/09/2017
|
||||||
|
* Remove node 0.6 from *.travis.yml*.
|
||||||
|
* Add *bignumber.mjs*.
|
||||||
|
|
||||||
|
#### 4.0.4
|
||||||
|
* 03/09/2017
|
||||||
|
* Add missing aliases to *bignumber.d.ts*.
|
||||||
|
|
||||||
|
#### 4.0.3
|
||||||
|
* 30/08/2017
|
||||||
|
* Add types: *bignumber.d.ts*.
|
||||||
|
|
||||||
|
#### 4.0.2
|
||||||
|
* 03/05/2017
|
||||||
|
* #120 Workaround Safari/Webkit bug.
|
||||||
|
|
||||||
|
#### 4.0.1
|
||||||
|
* 05/04/2017
|
||||||
|
* #121 BigNumber.default to BigNumber['default'].
|
||||||
|
|
||||||
|
#### 4.0.0
|
||||||
|
* 09/01/2017
|
||||||
|
* Replace BigNumber.isBigNumber method with isBigNumber prototype property.
|
||||||
|
|
||||||
|
#### 3.1.2
|
||||||
|
* 08/01/2017
|
||||||
|
* Minor documentation edit.
|
||||||
|
|
||||||
|
#### 3.1.1
|
||||||
|
* 08/01/2017
|
||||||
|
* Uncomment `isBigNumber` tests.
|
||||||
|
* Ignore dot files.
|
||||||
|
|
||||||
|
#### 3.1.0
|
||||||
|
* 08/01/2017
|
||||||
|
* Add `isBigNumber` method.
|
||||||
|
|
||||||
|
#### 3.0.2
|
||||||
|
* 08/01/2017
|
||||||
|
* Bugfix: Possible incorrect value of `ERRORS` after a `BigNumber.another` call (due to `parseNumeric` declaration in outer scope).
|
||||||
|
|
||||||
|
#### 3.0.1
|
||||||
|
* 23/11/2016
|
||||||
|
* Apply fix for old ipads with `%` issue, see #57 and #102.
|
||||||
|
* Correct error message.
|
||||||
|
|
||||||
|
#### 3.0.0
|
||||||
|
* 09/11/2016
|
||||||
|
* Remove `require('crypto')` - leave it to the user.
|
||||||
|
* Add `BigNumber.set` as `BigNumber.config` alias.
|
||||||
|
* Default `POW_PRECISION` to `0`.
|
||||||
|
|
||||||
|
#### 2.4.0
|
||||||
|
* 14/07/2016
|
||||||
|
* #97 Add exports to support ES6 imports.
|
||||||
|
|
||||||
|
#### 2.3.0
|
||||||
|
* 07/03/2016
|
||||||
|
* #86 Add modulus parameter to `toPower`.
|
||||||
|
|
||||||
|
#### 2.2.0
|
||||||
|
* 03/03/2016
|
||||||
|
* #91 Permit larger JS integers.
|
||||||
|
|
||||||
|
#### 2.1.4
|
||||||
|
* 15/12/2015
|
||||||
|
* Correct UMD.
|
||||||
|
|
||||||
|
#### 2.1.3
|
||||||
|
* 13/12/2015
|
||||||
|
* Refactor re global object and crypto availability when bundling.
|
||||||
|
|
||||||
|
#### 2.1.2
|
||||||
|
* 10/12/2015
|
||||||
|
* Bugfix: `window.crypto` not assigned to `crypto`.
|
||||||
|
|
||||||
|
#### 2.1.1
|
||||||
|
* 09/12/2015
|
||||||
|
* Prevent code bundler from adding `crypto` shim.
|
||||||
|
|
||||||
|
#### 2.1.0
|
||||||
|
* 26/10/2015
|
||||||
|
* For `valueOf` and `toJSON`, include the minus sign with negative zero.
|
||||||
|
|
||||||
|
#### 2.0.8
|
||||||
|
* 2/10/2015
|
||||||
|
* Internal round function bugfix.
|
||||||
|
|
||||||
|
#### 2.0.6
|
||||||
|
* 31/03/2015
|
||||||
|
* Add bower.json. Tweak division after in-depth review.
|
||||||
|
|
||||||
|
#### 2.0.5
|
||||||
|
* 25/03/2015
|
||||||
|
* Amend README. Remove bitcoin address.
|
||||||
|
|
||||||
|
#### 2.0.4
|
||||||
|
* 25/03/2015
|
||||||
|
* Critical bugfix #58: division.
|
||||||
|
|
||||||
|
#### 2.0.3
|
||||||
|
* 18/02/2015
|
||||||
|
* Amend README. Add source map.
|
||||||
|
|
||||||
|
#### 2.0.2
|
||||||
|
* 18/02/2015
|
||||||
|
* Correct links.
|
||||||
|
|
||||||
|
#### 2.0.1
|
||||||
|
* 18/02/2015
|
||||||
|
* Add `max`, `min`, `precision`, `random`, `shiftedBy`, `toDigits` and `truncated` methods.
|
||||||
|
* Add the short-forms: `add`, `mul`, `sd`, `sub` and `trunc`.
|
||||||
|
* Add an `another` method to enable multiple independent constructors to be created.
|
||||||
|
* Add support for the base 2, 8 and 16 prefixes `0b`, `0o` and `0x`.
|
||||||
|
* Enable a rounding mode to be specified as a second parameter to `toExponential`, `toFixed`, `toFormat` and `toPrecision`.
|
||||||
|
* Add a `CRYPTO` configuration property so cryptographically-secure pseudo-random number generation can be specified.
|
||||||
|
* Add a `MODULO_MODE` configuration property to enable the rounding mode used by the `modulo` operation to be specified.
|
||||||
|
* Add a `POW_PRECISION` configuration property to enable the number of significant digits calculated by the power operation to be limited.
|
||||||
|
* Improve code quality.
|
||||||
|
* Improve documentation.
|
||||||
|
|
||||||
|
#### 2.0.0
|
||||||
|
* 29/12/2014
|
||||||
|
* Add `dividedToIntegerBy`, `isInteger` and `toFormat` methods.
|
||||||
|
* Remove the following short-forms: `isF`, `isZ`, `toE`, `toF`, `toFr`, `toN`, `toP`, `toS`.
|
||||||
|
* Store a BigNumber's coefficient in base 1e14, rather than base 10.
|
||||||
|
* Add fast path for integers to BigNumber constructor.
|
||||||
|
* Incorporate the library into the online documentation.
|
||||||
|
|
||||||
|
#### 1.5.0
|
||||||
|
* 13/11/2014
|
||||||
|
* Add `toJSON` and `decimalPlaces` methods.
|
||||||
|
|
||||||
|
#### 1.4.1
|
||||||
|
* 08/06/2014
|
||||||
|
* Amend README.
|
||||||
|
|
||||||
|
#### 1.4.0
|
||||||
|
* 08/05/2014
|
||||||
|
* Add `toNumber`.
|
||||||
|
|
||||||
|
#### 1.3.0
|
||||||
|
* 08/11/2013
|
||||||
|
* Ensure correct rounding of `sqrt` in all, rather than almost all, cases.
|
||||||
|
* Maximum radix to 64.
|
||||||
|
|
||||||
|
#### 1.2.1
|
||||||
|
* 17/10/2013
|
||||||
|
* Sign of zero when x < 0 and x + (-x) = 0.
|
||||||
|
|
||||||
|
#### 1.2.0
|
||||||
|
* 19/9/2013
|
||||||
|
* Throw Error objects for stack.
|
||||||
|
|
||||||
|
#### 1.1.1
|
||||||
|
* 22/8/2013
|
||||||
|
* Show original value in constructor error message.
|
||||||
|
|
||||||
|
#### 1.1.0
|
||||||
|
* 1/8/2013
|
||||||
|
* Allow numbers with trailing radix point.
|
||||||
|
|
||||||
|
#### 1.0.1
|
||||||
|
* Bugfix: error messages with incorrect method name
|
||||||
|
|
||||||
|
#### 1.0.0
|
||||||
|
* 8/11/2012
|
||||||
|
* Initial release
|
||||||
23
node_modules/bignumber.js/LICENCE
generated
vendored
Normal file
23
node_modules/bignumber.js/LICENCE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
The MIT Licence.
|
||||||
|
|
||||||
|
Copyright (c) 2019 Michael Mclaughlin
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
'Software'), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER 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.
|
||||||
|
|
||||||
268
node_modules/bignumber.js/README.md
generated
vendored
Normal file
268
node_modules/bignumber.js/README.md
generated
vendored
Normal file
@@ -0,0 +1,268 @@
|
|||||||
|

|
||||||
|
|
||||||
|
A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic.
|
||||||
|
|
||||||
|
[](https://travis-ci.org/MikeMcl/bignumber.js)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Integers and decimals
|
||||||
|
- Simple API but full-featured
|
||||||
|
- Faster, smaller, and perhaps easier to use than JavaScript versions of Java's BigDecimal
|
||||||
|
- 8 KB minified and gzipped
|
||||||
|
- Replicates the `toExponential`, `toFixed`, `toPrecision` and `toString` methods of JavaScript's Number type
|
||||||
|
- Includes a `toFraction` and a correctly-rounded `squareRoot` method
|
||||||
|
- Supports cryptographically-secure pseudo-random number generation
|
||||||
|
- No dependencies
|
||||||
|
- Wide platform compatibility: uses JavaScript 1.5 (ECMAScript 3) features only
|
||||||
|
- Comprehensive [documentation](http://mikemcl.github.io/bignumber.js/) and test set
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
If a smaller and simpler library is required see [big.js](https://github.com/MikeMcl/big.js/).
|
||||||
|
It's less than half the size but only works with decimal numbers and only has half the methods.
|
||||||
|
It also does not allow `NaN` or `Infinity`, or have the configuration options of this library.
|
||||||
|
|
||||||
|
See also [decimal.js](https://github.com/MikeMcl/decimal.js/), which among other things adds support for non-integer powers, and performs all operations to a specified number of significant digits.
|
||||||
|
|
||||||
|
## Load
|
||||||
|
|
||||||
|
The library is the single JavaScript file *bignumber.js* (or minified, *bignumber.min.js*).
|
||||||
|
|
||||||
|
Browser:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script src='path/to/bignumber.js'></script>
|
||||||
|
```
|
||||||
|
|
||||||
|
[Node.js](http://nodejs.org):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm install bignumber.js
|
||||||
|
```
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const BigNumber = require('bignumber.js');
|
||||||
|
```
|
||||||
|
|
||||||
|
ES6 module:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
import BigNumber from "./bignumber.mjs"
|
||||||
|
```
|
||||||
|
|
||||||
|
AMD loader libraries such as [requireJS](http://requirejs.org/):
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
require(['bignumber'], function(BigNumber) {
|
||||||
|
// Use BigNumber here in local scope. No global BigNumber.
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
The library exports a single constructor function, [`BigNumber`](http://mikemcl.github.io/bignumber.js/#bignumber), which accepts a value of type Number, String or BigNumber,
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
let x = new BigNumber(123.4567);
|
||||||
|
let y = BigNumber('123456.7e-3');
|
||||||
|
let z = new BigNumber(x);
|
||||||
|
x.isEqualTo(y) && y.isEqualTo(z) && x.isEqualTo(z); // true
|
||||||
|
```
|
||||||
|
|
||||||
|
To get the string value of a BigNumber use [`toString()`](http://mikemcl.github.io/bignumber.js/#toS) or [`toFixed()`](http://mikemcl.github.io/bignumber.js/#toFix). Using `toFixed()` prevents exponential notation being returned, no matter how large or small the value.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
let x = new BigNumber('1111222233334444555566');
|
||||||
|
x.toString(); // "1.111222233334444555566e+21"
|
||||||
|
x.toFixed(); // "1111222233334444555566"
|
||||||
|
```
|
||||||
|
|
||||||
|
If the limited precision of Number values is not well understood, it is recommended to create BigNumbers from String values rather than Number values to avoid a potential loss of precision.
|
||||||
|
|
||||||
|
*In all further examples below, `let`, semicolons and `toString` calls are not shown. If a commented-out value is in quotes it means `toString` has been called on the preceding expression.*
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// Precision loss from using numeric literals with more than 15 significant digits.
|
||||||
|
new BigNumber(1.0000000000000001) // '1'
|
||||||
|
new BigNumber(88259496234518.57) // '88259496234518.56'
|
||||||
|
new BigNumber(99999999999999999999) // '100000000000000000000'
|
||||||
|
|
||||||
|
// Precision loss from using numeric literals outside the range of Number values.
|
||||||
|
new BigNumber(2e+308) // 'Infinity'
|
||||||
|
new BigNumber(1e-324) // '0'
|
||||||
|
|
||||||
|
// Precision loss from the unexpected result of arithmetic with Number values.
|
||||||
|
new BigNumber(0.7 + 0.1) // '0.7999999999999999'
|
||||||
|
```
|
||||||
|
|
||||||
|
When creating a BigNumber from a Number, note that a BigNumber is created from a Number's decimal `toString()` value not from its underlying binary value. If the latter is required, then pass the Number's `toString(2)` value and specify base 2.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
new BigNumber(Number.MAX_VALUE.toString(2), 2)
|
||||||
|
```
|
||||||
|
|
||||||
|
BigNumbers can be created from values in bases from 2 to 36. See [`ALPHABET`](http://mikemcl.github.io/bignumber.js/#alphabet) to extend this range.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
a = new BigNumber(1011, 2) // "11"
|
||||||
|
b = new BigNumber('zz.9', 36) // "1295.25"
|
||||||
|
c = a.plus(b) // "1306.25"
|
||||||
|
```
|
||||||
|
|
||||||
|
Performance is better if base 10 is NOT specified for decimal values. Only specify base 10 when it is desired that the number of decimal places of the input value be limited to the current [`DECIMAL_PLACES`](http://mikemcl.github.io/bignumber.js/#decimal-places) setting.
|
||||||
|
|
||||||
|
A BigNumber is immutable in the sense that it is not changed by its methods.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
0.3 - 0.1 // 0.19999999999999998
|
||||||
|
x = new BigNumber(0.3)
|
||||||
|
x.minus(0.1) // "0.2"
|
||||||
|
x // "0.3"
|
||||||
|
```
|
||||||
|
|
||||||
|
The methods that return a BigNumber can be chained.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
x.dividedBy(y).plus(z).times(9)
|
||||||
|
x.times('1.23456780123456789e+9').plus(9876.5432321).dividedBy('4444562598.111772').integerValue()
|
||||||
|
```
|
||||||
|
|
||||||
|
Some of the longer method names have a shorter alias.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
x.squareRoot().dividedBy(y).exponentiatedBy(3).isEqualTo(x.sqrt().div(y).pow(3)) // true
|
||||||
|
x.modulo(y).multipliedBy(z).eq(x.mod(y).times(z)) // true
|
||||||
|
```
|
||||||
|
|
||||||
|
As with JavaScript's Number type, there are [`toExponential`](http://mikemcl.github.io/bignumber.js/#toE), [`toFixed`](http://mikemcl.github.io/bignumber.js/#toFix) and [`toPrecision`](http://mikemcl.github.io/bignumber.js/#toP) methods.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
x = new BigNumber(255.5)
|
||||||
|
x.toExponential(5) // "2.55500e+2"
|
||||||
|
x.toFixed(5) // "255.50000"
|
||||||
|
x.toPrecision(5) // "255.50"
|
||||||
|
x.toNumber() // 255.5
|
||||||
|
```
|
||||||
|
|
||||||
|
A base can be specified for [`toString`](http://mikemcl.github.io/bignumber.js/#toS). Performance is better if base 10 is NOT specified, i.e. use `toString()` not `toString(10)`. Only specify base 10 when it is desired that the number of decimal places be limited to the current [`DECIMAL_PLACES`](http://mikemcl.github.io/bignumber.js/#decimal-places) setting.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
x.toString(16) // "ff.8"
|
||||||
|
```
|
||||||
|
|
||||||
|
There is a [`toFormat`](http://mikemcl.github.io/bignumber.js/#toFor) method which may be useful for internationalisation.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
y = new BigNumber('1234567.898765')
|
||||||
|
y.toFormat(2) // "1,234,567.90"
|
||||||
|
```
|
||||||
|
|
||||||
|
The maximum number of decimal places of the result of an operation involving division (i.e. a division, square root, base conversion or negative power operation) is set using the `set` or `config` method of the `BigNumber` constructor.
|
||||||
|
|
||||||
|
The other arithmetic operations always give the exact result.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
BigNumber.set({ DECIMAL_PLACES: 10, ROUNDING_MODE: 4 })
|
||||||
|
|
||||||
|
x = new BigNumber(2)
|
||||||
|
y = new BigNumber(3)
|
||||||
|
z = x.dividedBy(y) // "0.6666666667"
|
||||||
|
z.squareRoot() // "0.8164965809"
|
||||||
|
z.exponentiatedBy(-3) // "3.3749999995"
|
||||||
|
z.toString(2) // "0.1010101011"
|
||||||
|
z.multipliedBy(z) // "0.44444444448888888889"
|
||||||
|
z.multipliedBy(z).decimalPlaces(10) // "0.4444444445"
|
||||||
|
```
|
||||||
|
|
||||||
|
There is a [`toFraction`](http://mikemcl.github.io/bignumber.js/#toFr) method with an optional *maximum denominator* argument
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
y = new BigNumber(355)
|
||||||
|
pi = y.dividedBy(113) // "3.1415929204"
|
||||||
|
pi.toFraction() // [ "7853982301", "2500000000" ]
|
||||||
|
pi.toFraction(1000) // [ "355", "113" ]
|
||||||
|
```
|
||||||
|
|
||||||
|
and [`isNaN`](http://mikemcl.github.io/bignumber.js/#isNaN) and [`isFinite`](http://mikemcl.github.io/bignumber.js/#isF) methods, as `NaN` and `Infinity` are valid `BigNumber` values.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
x = new BigNumber(NaN) // "NaN"
|
||||||
|
y = new BigNumber(Infinity) // "Infinity"
|
||||||
|
x.isNaN() && !y.isNaN() && !x.isFinite() && !y.isFinite() // true
|
||||||
|
```
|
||||||
|
|
||||||
|
The value of a BigNumber is stored in a decimal floating point format in terms of a coefficient, exponent and sign.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
x = new BigNumber(-123.456);
|
||||||
|
x.c // [ 123, 45600000000000 ] coefficient (i.e. significand)
|
||||||
|
x.e // 2 exponent
|
||||||
|
x.s // -1 sign
|
||||||
|
```
|
||||||
|
|
||||||
|
For advanced usage, multiple BigNumber constructors can be created, each with their own independent configuration.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// Set DECIMAL_PLACES for the original BigNumber constructor
|
||||||
|
BigNumber.set({ DECIMAL_PLACES: 10 })
|
||||||
|
|
||||||
|
// Create another BigNumber constructor, optionally passing in a configuration object
|
||||||
|
BN = BigNumber.clone({ DECIMAL_PLACES: 5 })
|
||||||
|
|
||||||
|
x = new BigNumber(1)
|
||||||
|
y = new BN(1)
|
||||||
|
|
||||||
|
x.div(3) // '0.3333333333'
|
||||||
|
y.div(3) // '0.33333'
|
||||||
|
```
|
||||||
|
|
||||||
|
For further information see the [API](http://mikemcl.github.io/bignumber.js/) reference in the *doc* directory.
|
||||||
|
|
||||||
|
## Test
|
||||||
|
|
||||||
|
The *test/modules* directory contains the test scripts for each method.
|
||||||
|
|
||||||
|
The tests can be run with Node.js or a browser. For Node.js use
|
||||||
|
|
||||||
|
$ npm test
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
$ node test/test
|
||||||
|
|
||||||
|
To test a single method, use, for example
|
||||||
|
|
||||||
|
$ node test/methods/toFraction
|
||||||
|
|
||||||
|
For the browser, open *test/test.html*.
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
For Node, if [uglify-js](https://github.com/mishoo/UglifyJS2) is installed
|
||||||
|
|
||||||
|
npm install uglify-js -g
|
||||||
|
|
||||||
|
then
|
||||||
|
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
will create *bignumber.min.js*.
|
||||||
|
|
||||||
|
A source map will also be created in the root directory.
|
||||||
|
|
||||||
|
## Feedback
|
||||||
|
|
||||||
|
Open an issue, or email
|
||||||
|
|
||||||
|
Michael
|
||||||
|
|
||||||
|
<a href="mailto:M8ch88l@gmail.com">M8ch88l@gmail.com</a>
|
||||||
|
|
||||||
|
## Licence
|
||||||
|
|
||||||
|
The MIT Licence.
|
||||||
|
|
||||||
|
See [LICENCE](https://github.com/MikeMcl/bignumber.js/blob/master/LICENCE).
|
||||||
1829
node_modules/bignumber.js/bignumber.d.ts
generated
vendored
Normal file
1829
node_modules/bignumber.js/bignumber.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2902
node_modules/bignumber.js/bignumber.js
generated
vendored
Normal file
2902
node_modules/bignumber.js/bignumber.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/bignumber.js/bignumber.min.js
generated
vendored
Normal file
1
node_modules/bignumber.js/bignumber.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/bignumber.js/bignumber.min.js.map
generated
vendored
Normal file
1
node_modules/bignumber.js/bignumber.min.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2888
node_modules/bignumber.js/bignumber.mjs
generated
vendored
Normal file
2888
node_modules/bignumber.js/bignumber.mjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2237
node_modules/bignumber.js/doc/API.html
generated
vendored
Normal file
2237
node_modules/bignumber.js/doc/API.html
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
40
node_modules/bignumber.js/package.json
generated
vendored
Normal file
40
node_modules/bignumber.js/package.json
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"name": "bignumber.js",
|
||||||
|
"description": "A library for arbitrary-precision decimal and non-decimal arithmetic",
|
||||||
|
"version": "9.0.0",
|
||||||
|
"keywords": [
|
||||||
|
"arbitrary",
|
||||||
|
"precision",
|
||||||
|
"arithmetic",
|
||||||
|
"big",
|
||||||
|
"number",
|
||||||
|
"decimal",
|
||||||
|
"float",
|
||||||
|
"biginteger",
|
||||||
|
"bigdecimal",
|
||||||
|
"bignumber",
|
||||||
|
"bigint",
|
||||||
|
"bignum"
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/MikeMcl/bignumber.js.git"
|
||||||
|
},
|
||||||
|
"main": "bignumber",
|
||||||
|
"module": "bignumber.mjs",
|
||||||
|
"browser": "bignumber.js",
|
||||||
|
"types": "bignumber.d.ts",
|
||||||
|
"author": {
|
||||||
|
"name": "Michael Mclaughlin",
|
||||||
|
"email": "M8ch88l@gmail.com"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "*"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"scripts": {
|
||||||
|
"test": "node test/test",
|
||||||
|
"build": "uglifyjs bignumber.js --source-map -c -m -o bignumber.min.js"
|
||||||
|
},
|
||||||
|
"dependencies": {}
|
||||||
|
}
|
||||||
263
node_modules/binary-extensions/binary-extensions.json
generated
vendored
Normal file
263
node_modules/binary-extensions/binary-extensions.json
generated
vendored
Normal file
@@ -0,0 +1,263 @@
|
|||||||
|
[
|
||||||
|
"3dm",
|
||||||
|
"3ds",
|
||||||
|
"3g2",
|
||||||
|
"3gp",
|
||||||
|
"7z",
|
||||||
|
"a",
|
||||||
|
"aac",
|
||||||
|
"adp",
|
||||||
|
"afdesign",
|
||||||
|
"afphoto",
|
||||||
|
"afpub",
|
||||||
|
"ai",
|
||||||
|
"aif",
|
||||||
|
"aiff",
|
||||||
|
"alz",
|
||||||
|
"ape",
|
||||||
|
"apk",
|
||||||
|
"appimage",
|
||||||
|
"ar",
|
||||||
|
"arj",
|
||||||
|
"asf",
|
||||||
|
"au",
|
||||||
|
"avi",
|
||||||
|
"bak",
|
||||||
|
"baml",
|
||||||
|
"bh",
|
||||||
|
"bin",
|
||||||
|
"bk",
|
||||||
|
"bmp",
|
||||||
|
"btif",
|
||||||
|
"bz2",
|
||||||
|
"bzip2",
|
||||||
|
"cab",
|
||||||
|
"caf",
|
||||||
|
"cgm",
|
||||||
|
"class",
|
||||||
|
"cmx",
|
||||||
|
"cpio",
|
||||||
|
"cr2",
|
||||||
|
"cur",
|
||||||
|
"dat",
|
||||||
|
"dcm",
|
||||||
|
"deb",
|
||||||
|
"dex",
|
||||||
|
"djvu",
|
||||||
|
"dll",
|
||||||
|
"dmg",
|
||||||
|
"dng",
|
||||||
|
"doc",
|
||||||
|
"docm",
|
||||||
|
"docx",
|
||||||
|
"dot",
|
||||||
|
"dotm",
|
||||||
|
"dra",
|
||||||
|
"DS_Store",
|
||||||
|
"dsk",
|
||||||
|
"dts",
|
||||||
|
"dtshd",
|
||||||
|
"dvb",
|
||||||
|
"dwg",
|
||||||
|
"dxf",
|
||||||
|
"ecelp4800",
|
||||||
|
"ecelp7470",
|
||||||
|
"ecelp9600",
|
||||||
|
"egg",
|
||||||
|
"eol",
|
||||||
|
"eot",
|
||||||
|
"epub",
|
||||||
|
"exe",
|
||||||
|
"f4v",
|
||||||
|
"fbs",
|
||||||
|
"fh",
|
||||||
|
"fla",
|
||||||
|
"flac",
|
||||||
|
"flatpak",
|
||||||
|
"fli",
|
||||||
|
"flv",
|
||||||
|
"fpx",
|
||||||
|
"fst",
|
||||||
|
"fvt",
|
||||||
|
"g3",
|
||||||
|
"gh",
|
||||||
|
"gif",
|
||||||
|
"graffle",
|
||||||
|
"gz",
|
||||||
|
"gzip",
|
||||||
|
"h261",
|
||||||
|
"h263",
|
||||||
|
"h264",
|
||||||
|
"icns",
|
||||||
|
"ico",
|
||||||
|
"ief",
|
||||||
|
"img",
|
||||||
|
"ipa",
|
||||||
|
"iso",
|
||||||
|
"jar",
|
||||||
|
"jpeg",
|
||||||
|
"jpg",
|
||||||
|
"jpgv",
|
||||||
|
"jpm",
|
||||||
|
"jxr",
|
||||||
|
"key",
|
||||||
|
"ktx",
|
||||||
|
"lha",
|
||||||
|
"lib",
|
||||||
|
"lvp",
|
||||||
|
"lz",
|
||||||
|
"lzh",
|
||||||
|
"lzma",
|
||||||
|
"lzo",
|
||||||
|
"m3u",
|
||||||
|
"m4a",
|
||||||
|
"m4v",
|
||||||
|
"mar",
|
||||||
|
"mdi",
|
||||||
|
"mht",
|
||||||
|
"mid",
|
||||||
|
"midi",
|
||||||
|
"mj2",
|
||||||
|
"mka",
|
||||||
|
"mkv",
|
||||||
|
"mmr",
|
||||||
|
"mng",
|
||||||
|
"mobi",
|
||||||
|
"mov",
|
||||||
|
"movie",
|
||||||
|
"mp3",
|
||||||
|
"mp4",
|
||||||
|
"mp4a",
|
||||||
|
"mpeg",
|
||||||
|
"mpg",
|
||||||
|
"mpga",
|
||||||
|
"mxu",
|
||||||
|
"nef",
|
||||||
|
"npx",
|
||||||
|
"numbers",
|
||||||
|
"nupkg",
|
||||||
|
"o",
|
||||||
|
"odp",
|
||||||
|
"ods",
|
||||||
|
"odt",
|
||||||
|
"oga",
|
||||||
|
"ogg",
|
||||||
|
"ogv",
|
||||||
|
"otf",
|
||||||
|
"ott",
|
||||||
|
"pages",
|
||||||
|
"pbm",
|
||||||
|
"pcx",
|
||||||
|
"pdb",
|
||||||
|
"pdf",
|
||||||
|
"pea",
|
||||||
|
"pgm",
|
||||||
|
"pic",
|
||||||
|
"png",
|
||||||
|
"pnm",
|
||||||
|
"pot",
|
||||||
|
"potm",
|
||||||
|
"potx",
|
||||||
|
"ppa",
|
||||||
|
"ppam",
|
||||||
|
"ppm",
|
||||||
|
"pps",
|
||||||
|
"ppsm",
|
||||||
|
"ppsx",
|
||||||
|
"ppt",
|
||||||
|
"pptm",
|
||||||
|
"pptx",
|
||||||
|
"psd",
|
||||||
|
"pya",
|
||||||
|
"pyc",
|
||||||
|
"pyo",
|
||||||
|
"pyv",
|
||||||
|
"qt",
|
||||||
|
"rar",
|
||||||
|
"ras",
|
||||||
|
"raw",
|
||||||
|
"resources",
|
||||||
|
"rgb",
|
||||||
|
"rip",
|
||||||
|
"rlc",
|
||||||
|
"rmf",
|
||||||
|
"rmvb",
|
||||||
|
"rpm",
|
||||||
|
"rtf",
|
||||||
|
"rz",
|
||||||
|
"s3m",
|
||||||
|
"s7z",
|
||||||
|
"scpt",
|
||||||
|
"sgi",
|
||||||
|
"shar",
|
||||||
|
"snap",
|
||||||
|
"sil",
|
||||||
|
"sketch",
|
||||||
|
"slk",
|
||||||
|
"smv",
|
||||||
|
"snk",
|
||||||
|
"so",
|
||||||
|
"stl",
|
||||||
|
"suo",
|
||||||
|
"sub",
|
||||||
|
"swf",
|
||||||
|
"tar",
|
||||||
|
"tbz",
|
||||||
|
"tbz2",
|
||||||
|
"tga",
|
||||||
|
"tgz",
|
||||||
|
"thmx",
|
||||||
|
"tif",
|
||||||
|
"tiff",
|
||||||
|
"tlz",
|
||||||
|
"ttc",
|
||||||
|
"ttf",
|
||||||
|
"txz",
|
||||||
|
"udf",
|
||||||
|
"uvh",
|
||||||
|
"uvi",
|
||||||
|
"uvm",
|
||||||
|
"uvp",
|
||||||
|
"uvs",
|
||||||
|
"uvu",
|
||||||
|
"viv",
|
||||||
|
"vob",
|
||||||
|
"war",
|
||||||
|
"wav",
|
||||||
|
"wax",
|
||||||
|
"wbmp",
|
||||||
|
"wdp",
|
||||||
|
"weba",
|
||||||
|
"webm",
|
||||||
|
"webp",
|
||||||
|
"whl",
|
||||||
|
"wim",
|
||||||
|
"wm",
|
||||||
|
"wma",
|
||||||
|
"wmv",
|
||||||
|
"wmx",
|
||||||
|
"woff",
|
||||||
|
"woff2",
|
||||||
|
"wrm",
|
||||||
|
"wvx",
|
||||||
|
"xbm",
|
||||||
|
"xif",
|
||||||
|
"xla",
|
||||||
|
"xlam",
|
||||||
|
"xls",
|
||||||
|
"xlsb",
|
||||||
|
"xlsm",
|
||||||
|
"xlsx",
|
||||||
|
"xlt",
|
||||||
|
"xltm",
|
||||||
|
"xltx",
|
||||||
|
"xm",
|
||||||
|
"xmind",
|
||||||
|
"xpi",
|
||||||
|
"xpm",
|
||||||
|
"xwd",
|
||||||
|
"xz",
|
||||||
|
"z",
|
||||||
|
"zip",
|
||||||
|
"zipx"
|
||||||
|
]
|
||||||
3
node_modules/binary-extensions/binary-extensions.json.d.ts
generated
vendored
Normal file
3
node_modules/binary-extensions/binary-extensions.json.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
declare const binaryExtensionsJson: readonly string[];
|
||||||
|
|
||||||
|
export = binaryExtensionsJson;
|
||||||
14
node_modules/binary-extensions/index.d.ts
generated
vendored
Normal file
14
node_modules/binary-extensions/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
/**
|
||||||
|
List of binary file extensions.
|
||||||
|
|
||||||
|
@example
|
||||||
|
```
|
||||||
|
import binaryExtensions = require('binary-extensions');
|
||||||
|
|
||||||
|
console.log(binaryExtensions);
|
||||||
|
//=> ['3ds', '3g2', …]
|
||||||
|
```
|
||||||
|
*/
|
||||||
|
declare const binaryExtensions: readonly string[];
|
||||||
|
|
||||||
|
export = binaryExtensions;
|
||||||
1
node_modules/binary-extensions/index.js
generated
vendored
Normal file
1
node_modules/binary-extensions/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
module.exports = require('./binary-extensions.json');
|
||||||
10
node_modules/binary-extensions/license
generated
vendored
Normal file
10
node_modules/binary-extensions/license
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||||
|
Copyright (c) Paul Miller (https://paulmillr.com)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 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.
|
||||||
40
node_modules/binary-extensions/package.json
generated
vendored
Normal file
40
node_modules/binary-extensions/package.json
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"name": "binary-extensions",
|
||||||
|
"version": "2.3.0",
|
||||||
|
"description": "List of binary file extensions",
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "sindresorhus/binary-extensions",
|
||||||
|
"funding": "https://github.com/sponsors/sindresorhus",
|
||||||
|
"author": {
|
||||||
|
"name": "Sindre Sorhus",
|
||||||
|
"email": "sindresorhus@gmail.com",
|
||||||
|
"url": "https://sindresorhus.com"
|
||||||
|
},
|
||||||
|
"sideEffects": false,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "xo && ava && tsd"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"index.js",
|
||||||
|
"index.d.ts",
|
||||||
|
"binary-extensions.json",
|
||||||
|
"binary-extensions.json.d.ts"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"binary",
|
||||||
|
"extensions",
|
||||||
|
"extension",
|
||||||
|
"file",
|
||||||
|
"json",
|
||||||
|
"list",
|
||||||
|
"array"
|
||||||
|
],
|
||||||
|
"devDependencies": {
|
||||||
|
"ava": "^1.4.1",
|
||||||
|
"tsd": "^0.7.2",
|
||||||
|
"xo": "^0.24.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
25
node_modules/binary-extensions/readme.md
generated
vendored
Normal file
25
node_modules/binary-extensions/readme.md
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# binary-extensions
|
||||||
|
|
||||||
|
> List of binary file extensions
|
||||||
|
|
||||||
|
The list is just a [JSON file](binary-extensions.json) and can be used anywhere.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install binary-extensions
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
const binaryExtensions = require('binary-extensions');
|
||||||
|
|
||||||
|
console.log(binaryExtensions);
|
||||||
|
//=> ['3ds', '3g2', …]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Related
|
||||||
|
|
||||||
|
- [is-binary-path](https://github.com/sindresorhus/is-binary-path) - Check if a filepath is a binary file
|
||||||
|
- [text-extensions](https://github.com/sindresorhus/text-extensions) - List of text file extensions
|
||||||
672
node_modules/body-parser/HISTORY.md
generated
vendored
Normal file
672
node_modules/body-parser/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,672 @@
|
|||||||
|
1.20.3 / 2024-09-10
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: qs@6.13.0
|
||||||
|
* add `depth` option to customize the depth level in the parser
|
||||||
|
* IMPORTANT: The default `depth` level for parsing URL-encoded data is now `32` (previously was `Infinity`)
|
||||||
|
|
||||||
|
1.20.2 / 2023-02-21
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Fix strict json error message on Node.js 19+
|
||||||
|
* deps: content-type@~1.0.5
|
||||||
|
- perf: skip value escaping when unnecessary
|
||||||
|
* deps: raw-body@2.5.2
|
||||||
|
|
||||||
|
1.20.1 / 2022-10-06
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: qs@6.11.0
|
||||||
|
* perf: remove unnecessary object clone
|
||||||
|
|
||||||
|
1.20.0 / 2022-04-02
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Fix error message for json parse whitespace in `strict`
|
||||||
|
* Fix internal error when inflated body exceeds limit
|
||||||
|
* Prevent loss of async hooks context
|
||||||
|
* Prevent hanging when request already read
|
||||||
|
* deps: depd@2.0.0
|
||||||
|
- Replace internal `eval` usage with `Function` constructor
|
||||||
|
- Use instance methods on `process` to check for listeners
|
||||||
|
* deps: http-errors@2.0.0
|
||||||
|
- deps: depd@2.0.0
|
||||||
|
- deps: statuses@2.0.1
|
||||||
|
* deps: on-finished@2.4.1
|
||||||
|
* deps: qs@6.10.3
|
||||||
|
* deps: raw-body@2.5.1
|
||||||
|
- deps: http-errors@2.0.0
|
||||||
|
|
||||||
|
1.19.2 / 2022-02-15
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: bytes@3.1.2
|
||||||
|
* deps: qs@6.9.7
|
||||||
|
* Fix handling of `__proto__` keys
|
||||||
|
* deps: raw-body@2.4.3
|
||||||
|
- deps: bytes@3.1.2
|
||||||
|
|
||||||
|
1.19.1 / 2021-12-10
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: bytes@3.1.1
|
||||||
|
* deps: http-errors@1.8.1
|
||||||
|
- deps: inherits@2.0.4
|
||||||
|
- deps: toidentifier@1.0.1
|
||||||
|
- deps: setprototypeof@1.2.0
|
||||||
|
* deps: qs@6.9.6
|
||||||
|
* deps: raw-body@2.4.2
|
||||||
|
- deps: bytes@3.1.1
|
||||||
|
- deps: http-errors@1.8.1
|
||||||
|
* deps: safe-buffer@5.2.1
|
||||||
|
* deps: type-is@~1.6.18
|
||||||
|
|
||||||
|
1.19.0 / 2019-04-25
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: bytes@3.1.0
|
||||||
|
- Add petabyte (`pb`) support
|
||||||
|
* deps: http-errors@1.7.2
|
||||||
|
- Set constructor name when possible
|
||||||
|
- deps: setprototypeof@1.1.1
|
||||||
|
- deps: statuses@'>= 1.5.0 < 2'
|
||||||
|
* deps: iconv-lite@0.4.24
|
||||||
|
- Added encoding MIK
|
||||||
|
* deps: qs@6.7.0
|
||||||
|
- Fix parsing array brackets after index
|
||||||
|
* deps: raw-body@2.4.0
|
||||||
|
- deps: bytes@3.1.0
|
||||||
|
- deps: http-errors@1.7.2
|
||||||
|
- deps: iconv-lite@0.4.24
|
||||||
|
* deps: type-is@~1.6.17
|
||||||
|
- deps: mime-types@~2.1.24
|
||||||
|
- perf: prevent internal `throw` on invalid type
|
||||||
|
|
||||||
|
1.18.3 / 2018-05-14
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Fix stack trace for strict json parse error
|
||||||
|
* deps: depd@~1.1.2
|
||||||
|
- perf: remove argument reassignment
|
||||||
|
* deps: http-errors@~1.6.3
|
||||||
|
- deps: depd@~1.1.2
|
||||||
|
- deps: setprototypeof@1.1.0
|
||||||
|
- deps: statuses@'>= 1.3.1 < 2'
|
||||||
|
* deps: iconv-lite@0.4.23
|
||||||
|
- Fix loading encoding with year appended
|
||||||
|
- Fix deprecation warnings on Node.js 10+
|
||||||
|
* deps: qs@6.5.2
|
||||||
|
* deps: raw-body@2.3.3
|
||||||
|
- deps: http-errors@1.6.3
|
||||||
|
- deps: iconv-lite@0.4.23
|
||||||
|
* deps: type-is@~1.6.16
|
||||||
|
- deps: mime-types@~2.1.18
|
||||||
|
|
||||||
|
1.18.2 / 2017-09-22
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: debug@2.6.9
|
||||||
|
* perf: remove argument reassignment
|
||||||
|
|
||||||
|
1.18.1 / 2017-09-12
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: content-type@~1.0.4
|
||||||
|
- perf: remove argument reassignment
|
||||||
|
- perf: skip parameter parsing when no parameters
|
||||||
|
* deps: iconv-lite@0.4.19
|
||||||
|
- Fix ISO-8859-1 regression
|
||||||
|
- Update Windows-1255
|
||||||
|
* deps: qs@6.5.1
|
||||||
|
- Fix parsing & compacting very deep objects
|
||||||
|
* deps: raw-body@2.3.2
|
||||||
|
- deps: iconv-lite@0.4.19
|
||||||
|
|
||||||
|
1.18.0 / 2017-09-08
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Fix JSON strict violation error to match native parse error
|
||||||
|
* Include the `body` property on verify errors
|
||||||
|
* Include the `type` property on all generated errors
|
||||||
|
* Use `http-errors` to set status code on errors
|
||||||
|
* deps: bytes@3.0.0
|
||||||
|
* deps: debug@2.6.8
|
||||||
|
* deps: depd@~1.1.1
|
||||||
|
- Remove unnecessary `Buffer` loading
|
||||||
|
* deps: http-errors@~1.6.2
|
||||||
|
- deps: depd@1.1.1
|
||||||
|
* deps: iconv-lite@0.4.18
|
||||||
|
- Add support for React Native
|
||||||
|
- Add a warning if not loaded as utf-8
|
||||||
|
- Fix CESU-8 decoding in Node.js 8
|
||||||
|
- Improve speed of ISO-8859-1 encoding
|
||||||
|
* deps: qs@6.5.0
|
||||||
|
* deps: raw-body@2.3.1
|
||||||
|
- Use `http-errors` for standard emitted errors
|
||||||
|
- deps: bytes@3.0.0
|
||||||
|
- deps: iconv-lite@0.4.18
|
||||||
|
- perf: skip buffer decoding on overage chunk
|
||||||
|
* perf: prevent internal `throw` when missing charset
|
||||||
|
|
||||||
|
1.17.2 / 2017-05-17
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: debug@2.6.7
|
||||||
|
- Fix `DEBUG_MAX_ARRAY_LENGTH`
|
||||||
|
- deps: ms@2.0.0
|
||||||
|
* deps: type-is@~1.6.15
|
||||||
|
- deps: mime-types@~2.1.15
|
||||||
|
|
||||||
|
1.17.1 / 2017-03-06
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: qs@6.4.0
|
||||||
|
- Fix regression parsing keys starting with `[`
|
||||||
|
|
||||||
|
1.17.0 / 2017-03-01
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: http-errors@~1.6.1
|
||||||
|
- Make `message` property enumerable for `HttpError`s
|
||||||
|
- deps: setprototypeof@1.0.3
|
||||||
|
* deps: qs@6.3.1
|
||||||
|
- Fix compacting nested arrays
|
||||||
|
|
||||||
|
1.16.1 / 2017-02-10
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: debug@2.6.1
|
||||||
|
- Fix deprecation messages in WebStorm and other editors
|
||||||
|
- Undeprecate `DEBUG_FD` set to `1` or `2`
|
||||||
|
|
||||||
|
1.16.0 / 2017-01-17
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: debug@2.6.0
|
||||||
|
- Allow colors in workers
|
||||||
|
- Deprecated `DEBUG_FD` environment variable
|
||||||
|
- Fix error when running under React Native
|
||||||
|
- Use same color for same namespace
|
||||||
|
- deps: ms@0.7.2
|
||||||
|
* deps: http-errors@~1.5.1
|
||||||
|
- deps: inherits@2.0.3
|
||||||
|
- deps: setprototypeof@1.0.2
|
||||||
|
- deps: statuses@'>= 1.3.1 < 2'
|
||||||
|
* deps: iconv-lite@0.4.15
|
||||||
|
- Added encoding MS-31J
|
||||||
|
- Added encoding MS-932
|
||||||
|
- Added encoding MS-936
|
||||||
|
- Added encoding MS-949
|
||||||
|
- Added encoding MS-950
|
||||||
|
- Fix GBK/GB18030 handling of Euro character
|
||||||
|
* deps: qs@6.2.1
|
||||||
|
- Fix array parsing from skipping empty values
|
||||||
|
* deps: raw-body@~2.2.0
|
||||||
|
- deps: iconv-lite@0.4.15
|
||||||
|
* deps: type-is@~1.6.14
|
||||||
|
- deps: mime-types@~2.1.13
|
||||||
|
|
||||||
|
1.15.2 / 2016-06-19
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: bytes@2.4.0
|
||||||
|
* deps: content-type@~1.0.2
|
||||||
|
- perf: enable strict mode
|
||||||
|
* deps: http-errors@~1.5.0
|
||||||
|
- Use `setprototypeof` module to replace `__proto__` setting
|
||||||
|
- deps: statuses@'>= 1.3.0 < 2'
|
||||||
|
- perf: enable strict mode
|
||||||
|
* deps: qs@6.2.0
|
||||||
|
* deps: raw-body@~2.1.7
|
||||||
|
- deps: bytes@2.4.0
|
||||||
|
- perf: remove double-cleanup on happy path
|
||||||
|
* deps: type-is@~1.6.13
|
||||||
|
- deps: mime-types@~2.1.11
|
||||||
|
|
||||||
|
1.15.1 / 2016-05-05
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: bytes@2.3.0
|
||||||
|
- Drop partial bytes on all parsed units
|
||||||
|
- Fix parsing byte string that looks like hex
|
||||||
|
* deps: raw-body@~2.1.6
|
||||||
|
- deps: bytes@2.3.0
|
||||||
|
* deps: type-is@~1.6.12
|
||||||
|
- deps: mime-types@~2.1.10
|
||||||
|
|
||||||
|
1.15.0 / 2016-02-10
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: http-errors@~1.4.0
|
||||||
|
- Add `HttpError` export, for `err instanceof createError.HttpError`
|
||||||
|
- deps: inherits@2.0.1
|
||||||
|
- deps: statuses@'>= 1.2.1 < 2'
|
||||||
|
* deps: qs@6.1.0
|
||||||
|
* deps: type-is@~1.6.11
|
||||||
|
- deps: mime-types@~2.1.9
|
||||||
|
|
||||||
|
1.14.2 / 2015-12-16
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: bytes@2.2.0
|
||||||
|
* deps: iconv-lite@0.4.13
|
||||||
|
* deps: qs@5.2.0
|
||||||
|
* deps: raw-body@~2.1.5
|
||||||
|
- deps: bytes@2.2.0
|
||||||
|
- deps: iconv-lite@0.4.13
|
||||||
|
* deps: type-is@~1.6.10
|
||||||
|
- deps: mime-types@~2.1.8
|
||||||
|
|
||||||
|
1.14.1 / 2015-09-27
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Fix issue where invalid charset results in 400 when `verify` used
|
||||||
|
* deps: iconv-lite@0.4.12
|
||||||
|
- Fix CESU-8 decoding in Node.js 4.x
|
||||||
|
* deps: raw-body@~2.1.4
|
||||||
|
- Fix masking critical errors from `iconv-lite`
|
||||||
|
- deps: iconv-lite@0.4.12
|
||||||
|
* deps: type-is@~1.6.9
|
||||||
|
- deps: mime-types@~2.1.7
|
||||||
|
|
||||||
|
1.14.0 / 2015-09-16
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Fix JSON strict parse error to match syntax errors
|
||||||
|
* Provide static `require` analysis in `urlencoded` parser
|
||||||
|
* deps: depd@~1.1.0
|
||||||
|
- Support web browser loading
|
||||||
|
* deps: qs@5.1.0
|
||||||
|
* deps: raw-body@~2.1.3
|
||||||
|
- Fix sync callback when attaching data listener causes sync read
|
||||||
|
* deps: type-is@~1.6.8
|
||||||
|
- Fix type error when given invalid type to match against
|
||||||
|
- deps: mime-types@~2.1.6
|
||||||
|
|
||||||
|
1.13.3 / 2015-07-31
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: type-is@~1.6.6
|
||||||
|
- deps: mime-types@~2.1.4
|
||||||
|
|
||||||
|
1.13.2 / 2015-07-05
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: iconv-lite@0.4.11
|
||||||
|
* deps: qs@4.0.0
|
||||||
|
- Fix dropping parameters like `hasOwnProperty`
|
||||||
|
- Fix user-visible incompatibilities from 3.1.0
|
||||||
|
- Fix various parsing edge cases
|
||||||
|
* deps: raw-body@~2.1.2
|
||||||
|
- Fix error stack traces to skip `makeError`
|
||||||
|
- deps: iconv-lite@0.4.11
|
||||||
|
* deps: type-is@~1.6.4
|
||||||
|
- deps: mime-types@~2.1.2
|
||||||
|
- perf: enable strict mode
|
||||||
|
- perf: remove argument reassignment
|
||||||
|
|
||||||
|
1.13.1 / 2015-06-16
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: qs@2.4.2
|
||||||
|
- Downgraded from 3.1.0 because of user-visible incompatibilities
|
||||||
|
|
||||||
|
1.13.0 / 2015-06-14
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Add `statusCode` property on `Error`s, in addition to `status`
|
||||||
|
* Change `type` default to `application/json` for JSON parser
|
||||||
|
* Change `type` default to `application/x-www-form-urlencoded` for urlencoded parser
|
||||||
|
* Provide static `require` analysis
|
||||||
|
* Use the `http-errors` module to generate errors
|
||||||
|
* deps: bytes@2.1.0
|
||||||
|
- Slight optimizations
|
||||||
|
* deps: iconv-lite@0.4.10
|
||||||
|
- The encoding UTF-16 without BOM now defaults to UTF-16LE when detection fails
|
||||||
|
- Leading BOM is now removed when decoding
|
||||||
|
* deps: on-finished@~2.3.0
|
||||||
|
- Add defined behavior for HTTP `CONNECT` requests
|
||||||
|
- Add defined behavior for HTTP `Upgrade` requests
|
||||||
|
- deps: ee-first@1.1.1
|
||||||
|
* deps: qs@3.1.0
|
||||||
|
- Fix dropping parameters like `hasOwnProperty`
|
||||||
|
- Fix various parsing edge cases
|
||||||
|
- Parsed object now has `null` prototype
|
||||||
|
* deps: raw-body@~2.1.1
|
||||||
|
- Use `unpipe` module for unpiping requests
|
||||||
|
- deps: iconv-lite@0.4.10
|
||||||
|
* deps: type-is@~1.6.3
|
||||||
|
- deps: mime-types@~2.1.1
|
||||||
|
- perf: reduce try block size
|
||||||
|
- perf: remove bitwise operations
|
||||||
|
* perf: enable strict mode
|
||||||
|
* perf: remove argument reassignment
|
||||||
|
* perf: remove delete call
|
||||||
|
|
||||||
|
1.12.4 / 2015-05-10
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: debug@~2.2.0
|
||||||
|
* deps: qs@2.4.2
|
||||||
|
- Fix allowing parameters like `constructor`
|
||||||
|
* deps: on-finished@~2.2.1
|
||||||
|
* deps: raw-body@~2.0.1
|
||||||
|
- Fix a false-positive when unpiping in Node.js 0.8
|
||||||
|
- deps: bytes@2.0.1
|
||||||
|
* deps: type-is@~1.6.2
|
||||||
|
- deps: mime-types@~2.0.11
|
||||||
|
|
||||||
|
1.12.3 / 2015-04-15
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Slight efficiency improvement when not debugging
|
||||||
|
* deps: depd@~1.0.1
|
||||||
|
* deps: iconv-lite@0.4.8
|
||||||
|
- Add encoding alias UNICODE-1-1-UTF-7
|
||||||
|
* deps: raw-body@1.3.4
|
||||||
|
- Fix hanging callback if request aborts during read
|
||||||
|
- deps: iconv-lite@0.4.8
|
||||||
|
|
||||||
|
1.12.2 / 2015-03-16
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: qs@2.4.1
|
||||||
|
- Fix error when parameter `hasOwnProperty` is present
|
||||||
|
|
||||||
|
1.12.1 / 2015-03-15
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: debug@~2.1.3
|
||||||
|
- Fix high intensity foreground color for bold
|
||||||
|
- deps: ms@0.7.0
|
||||||
|
* deps: type-is@~1.6.1
|
||||||
|
- deps: mime-types@~2.0.10
|
||||||
|
|
||||||
|
1.12.0 / 2015-02-13
|
||||||
|
===================
|
||||||
|
|
||||||
|
* add `debug` messages
|
||||||
|
* accept a function for the `type` option
|
||||||
|
* use `content-type` to parse `Content-Type` headers
|
||||||
|
* deps: iconv-lite@0.4.7
|
||||||
|
- Gracefully support enumerables on `Object.prototype`
|
||||||
|
* deps: raw-body@1.3.3
|
||||||
|
- deps: iconv-lite@0.4.7
|
||||||
|
* deps: type-is@~1.6.0
|
||||||
|
- fix argument reassignment
|
||||||
|
- fix false-positives in `hasBody` `Transfer-Encoding` check
|
||||||
|
- support wildcard for both type and subtype (`*/*`)
|
||||||
|
- deps: mime-types@~2.0.9
|
||||||
|
|
||||||
|
1.11.0 / 2015-01-30
|
||||||
|
===================
|
||||||
|
|
||||||
|
* make internal `extended: true` depth limit infinity
|
||||||
|
* deps: type-is@~1.5.6
|
||||||
|
- deps: mime-types@~2.0.8
|
||||||
|
|
||||||
|
1.10.2 / 2015-01-20
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: iconv-lite@0.4.6
|
||||||
|
- Fix rare aliases of single-byte encodings
|
||||||
|
* deps: raw-body@1.3.2
|
||||||
|
- deps: iconv-lite@0.4.6
|
||||||
|
|
||||||
|
1.10.1 / 2015-01-01
|
||||||
|
===================
|
||||||
|
|
||||||
|
* deps: on-finished@~2.2.0
|
||||||
|
* deps: type-is@~1.5.5
|
||||||
|
- deps: mime-types@~2.0.7
|
||||||
|
|
||||||
|
1.10.0 / 2014-12-02
|
||||||
|
===================
|
||||||
|
|
||||||
|
* make internal `extended: true` array limit dynamic
|
||||||
|
|
||||||
|
1.9.3 / 2014-11-21
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: iconv-lite@0.4.5
|
||||||
|
- Fix Windows-31J and X-SJIS encoding support
|
||||||
|
* deps: qs@2.3.3
|
||||||
|
- Fix `arrayLimit` behavior
|
||||||
|
* deps: raw-body@1.3.1
|
||||||
|
- deps: iconv-lite@0.4.5
|
||||||
|
* deps: type-is@~1.5.3
|
||||||
|
- deps: mime-types@~2.0.3
|
||||||
|
|
||||||
|
1.9.2 / 2014-10-27
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: qs@2.3.2
|
||||||
|
- Fix parsing of mixed objects and values
|
||||||
|
|
||||||
|
1.9.1 / 2014-10-22
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: on-finished@~2.1.1
|
||||||
|
- Fix handling of pipelined requests
|
||||||
|
* deps: qs@2.3.0
|
||||||
|
- Fix parsing of mixed implicit and explicit arrays
|
||||||
|
* deps: type-is@~1.5.2
|
||||||
|
- deps: mime-types@~2.0.2
|
||||||
|
|
||||||
|
1.9.0 / 2014-09-24
|
||||||
|
==================
|
||||||
|
|
||||||
|
* include the charset in "unsupported charset" error message
|
||||||
|
* include the encoding in "unsupported content encoding" error message
|
||||||
|
* deps: depd@~1.0.0
|
||||||
|
|
||||||
|
1.8.4 / 2014-09-23
|
||||||
|
==================
|
||||||
|
|
||||||
|
* fix content encoding to be case-insensitive
|
||||||
|
|
||||||
|
1.8.3 / 2014-09-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: qs@2.2.4
|
||||||
|
- Fix issue with object keys starting with numbers truncated
|
||||||
|
|
||||||
|
1.8.2 / 2014-09-15
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: depd@0.4.5
|
||||||
|
|
||||||
|
1.8.1 / 2014-09-07
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: media-typer@0.3.0
|
||||||
|
* deps: type-is@~1.5.1
|
||||||
|
|
||||||
|
1.8.0 / 2014-09-05
|
||||||
|
==================
|
||||||
|
|
||||||
|
* make empty-body-handling consistent between chunked requests
|
||||||
|
- empty `json` produces `{}`
|
||||||
|
- empty `raw` produces `new Buffer(0)`
|
||||||
|
- empty `text` produces `''`
|
||||||
|
- empty `urlencoded` produces `{}`
|
||||||
|
* deps: qs@2.2.3
|
||||||
|
- Fix issue where first empty value in array is discarded
|
||||||
|
* deps: type-is@~1.5.0
|
||||||
|
- fix `hasbody` to be true for `content-length: 0`
|
||||||
|
|
||||||
|
1.7.0 / 2014-09-01
|
||||||
|
==================
|
||||||
|
|
||||||
|
* add `parameterLimit` option to `urlencoded` parser
|
||||||
|
* change `urlencoded` extended array limit to 100
|
||||||
|
* respond with 413 when over `parameterLimit` in `urlencoded`
|
||||||
|
|
||||||
|
1.6.7 / 2014-08-29
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: qs@2.2.2
|
||||||
|
- Remove unnecessary cloning
|
||||||
|
|
||||||
|
1.6.6 / 2014-08-27
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: qs@2.2.0
|
||||||
|
- Array parsing fix
|
||||||
|
- Performance improvements
|
||||||
|
|
||||||
|
1.6.5 / 2014-08-16
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: on-finished@2.1.0
|
||||||
|
|
||||||
|
1.6.4 / 2014-08-14
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: qs@1.2.2
|
||||||
|
|
||||||
|
1.6.3 / 2014-08-10
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: qs@1.2.1
|
||||||
|
|
||||||
|
1.6.2 / 2014-08-07
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: qs@1.2.0
|
||||||
|
- Fix parsing array of objects
|
||||||
|
|
||||||
|
1.6.1 / 2014-08-06
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: qs@1.1.0
|
||||||
|
- Accept urlencoded square brackets
|
||||||
|
- Accept empty values in implicit array notation
|
||||||
|
|
||||||
|
1.6.0 / 2014-08-05
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: qs@1.0.2
|
||||||
|
- Complete rewrite
|
||||||
|
- Limits array length to 20
|
||||||
|
- Limits object depth to 5
|
||||||
|
- Limits parameters to 1,000
|
||||||
|
|
||||||
|
1.5.2 / 2014-07-27
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: depd@0.4.4
|
||||||
|
- Work-around v8 generating empty stack traces
|
||||||
|
|
||||||
|
1.5.1 / 2014-07-26
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: depd@0.4.3
|
||||||
|
- Fix exception when global `Error.stackTraceLimit` is too low
|
||||||
|
|
||||||
|
1.5.0 / 2014-07-20
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: depd@0.4.2
|
||||||
|
- Add `TRACE_DEPRECATION` environment variable
|
||||||
|
- Remove non-standard grey color from color output
|
||||||
|
- Support `--no-deprecation` argument
|
||||||
|
- Support `--trace-deprecation` argument
|
||||||
|
* deps: iconv-lite@0.4.4
|
||||||
|
- Added encoding UTF-7
|
||||||
|
* deps: raw-body@1.3.0
|
||||||
|
- deps: iconv-lite@0.4.4
|
||||||
|
- Added encoding UTF-7
|
||||||
|
- Fix `Cannot switch to old mode now` error on Node.js 0.10+
|
||||||
|
* deps: type-is@~1.3.2
|
||||||
|
|
||||||
|
1.4.3 / 2014-06-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: type-is@1.3.1
|
||||||
|
- fix global variable leak
|
||||||
|
|
||||||
|
1.4.2 / 2014-06-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: type-is@1.3.0
|
||||||
|
- improve type parsing
|
||||||
|
|
||||||
|
1.4.1 / 2014-06-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* fix urlencoded extended deprecation message
|
||||||
|
|
||||||
|
1.4.0 / 2014-06-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* add `text` parser
|
||||||
|
* add `raw` parser
|
||||||
|
* check accepted charset in content-type (accepts utf-8)
|
||||||
|
* check accepted encoding in content-encoding (accepts identity)
|
||||||
|
* deprecate `bodyParser()` middleware; use `.json()` and `.urlencoded()` as needed
|
||||||
|
* deprecate `urlencoded()` without provided `extended` option
|
||||||
|
* lazy-load urlencoded parsers
|
||||||
|
* parsers split into files for reduced mem usage
|
||||||
|
* support gzip and deflate bodies
|
||||||
|
- set `inflate: false` to turn off
|
||||||
|
* deps: raw-body@1.2.2
|
||||||
|
- Support all encodings from `iconv-lite`
|
||||||
|
|
||||||
|
1.3.1 / 2014-06-11
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: type-is@1.2.1
|
||||||
|
- Switch dependency from mime to mime-types@1.0.0
|
||||||
|
|
||||||
|
1.3.0 / 2014-05-31
|
||||||
|
==================
|
||||||
|
|
||||||
|
* add `extended` option to urlencoded parser
|
||||||
|
|
||||||
|
1.2.2 / 2014-05-27
|
||||||
|
==================
|
||||||
|
|
||||||
|
* deps: raw-body@1.1.6
|
||||||
|
- assert stream encoding on node.js 0.8
|
||||||
|
- assert stream encoding on node.js < 0.10.6
|
||||||
|
- deps: bytes@1
|
||||||
|
|
||||||
|
1.2.1 / 2014-05-26
|
||||||
|
==================
|
||||||
|
|
||||||
|
* invoke `next(err)` after request fully read
|
||||||
|
- prevents hung responses and socket hang ups
|
||||||
|
|
||||||
|
1.2.0 / 2014-05-11
|
||||||
|
==================
|
||||||
|
|
||||||
|
* add `verify` option
|
||||||
|
* deps: type-is@1.2.0
|
||||||
|
- support suffix matching
|
||||||
|
|
||||||
|
1.1.2 / 2014-05-11
|
||||||
|
==================
|
||||||
|
|
||||||
|
* improve json parser speed
|
||||||
|
|
||||||
|
1.1.1 / 2014-05-11
|
||||||
|
==================
|
||||||
|
|
||||||
|
* fix repeated limit parsing with every request
|
||||||
|
|
||||||
|
1.1.0 / 2014-05-10
|
||||||
|
==================
|
||||||
|
|
||||||
|
* add `type` option
|
||||||
|
* deps: pin for safety and consistency
|
||||||
|
|
||||||
|
1.0.2 / 2014-04-14
|
||||||
|
==================
|
||||||
|
|
||||||
|
* use `type-is` module
|
||||||
|
|
||||||
|
1.0.1 / 2014-03-20
|
||||||
|
==================
|
||||||
|
|
||||||
|
* lower default limits to 100kb
|
||||||
23
node_modules/body-parser/LICENSE
generated
vendored
Normal file
23
node_modules/body-parser/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
|
||||||
|
Copyright (c) 2014-2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
'Software'), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER 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.
|
||||||
476
node_modules/body-parser/README.md
generated
vendored
Normal file
476
node_modules/body-parser/README.md
generated
vendored
Normal file
@@ -0,0 +1,476 @@
|
|||||||
|
# body-parser
|
||||||
|
|
||||||
|
[![NPM Version][npm-version-image]][npm-url]
|
||||||
|
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||||
|
[![Build Status][ci-image]][ci-url]
|
||||||
|
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||||
|
[![OpenSSF Scorecard Badge][ossf-scorecard-badge]][ossf-scorecard-visualizer]
|
||||||
|
|
||||||
|
Node.js body parsing middleware.
|
||||||
|
|
||||||
|
Parse incoming request bodies in a middleware before your handlers, available
|
||||||
|
under the `req.body` property.
|
||||||
|
|
||||||
|
**Note** As `req.body`'s shape is based on user-controlled input, all
|
||||||
|
properties and values in this object are untrusted and should be validated
|
||||||
|
before trusting. For example, `req.body.foo.toString()` may fail in multiple
|
||||||
|
ways, for example the `foo` property may not be there or may not be a string,
|
||||||
|
and `toString` may not be a function and instead a string or other user input.
|
||||||
|
|
||||||
|
[Learn about the anatomy of an HTTP transaction in Node.js](https://nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/).
|
||||||
|
|
||||||
|
_This does not handle multipart bodies_, due to their complex and typically
|
||||||
|
large nature. For multipart bodies, you may be interested in the following
|
||||||
|
modules:
|
||||||
|
|
||||||
|
* [busboy](https://www.npmjs.org/package/busboy#readme) and
|
||||||
|
[connect-busboy](https://www.npmjs.org/package/connect-busboy#readme)
|
||||||
|
* [multiparty](https://www.npmjs.org/package/multiparty#readme) and
|
||||||
|
[connect-multiparty](https://www.npmjs.org/package/connect-multiparty#readme)
|
||||||
|
* [formidable](https://www.npmjs.org/package/formidable#readme)
|
||||||
|
* [multer](https://www.npmjs.org/package/multer#readme)
|
||||||
|
|
||||||
|
This module provides the following parsers:
|
||||||
|
|
||||||
|
* [JSON body parser](#bodyparserjsonoptions)
|
||||||
|
* [Raw body parser](#bodyparserrawoptions)
|
||||||
|
* [Text body parser](#bodyparsertextoptions)
|
||||||
|
* [URL-encoded form body parser](#bodyparserurlencodedoptions)
|
||||||
|
|
||||||
|
Other body parsers you might be interested in:
|
||||||
|
|
||||||
|
- [body](https://www.npmjs.org/package/body#readme)
|
||||||
|
- [co-body](https://www.npmjs.org/package/co-body#readme)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install body-parser
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
```js
|
||||||
|
var bodyParser = require('body-parser')
|
||||||
|
```
|
||||||
|
|
||||||
|
The `bodyParser` object exposes various factories to create middlewares. All
|
||||||
|
middlewares will populate the `req.body` property with the parsed body when
|
||||||
|
the `Content-Type` request header matches the `type` option, or an empty
|
||||||
|
object (`{}`) if there was no body to parse, the `Content-Type` was not matched,
|
||||||
|
or an error occurred.
|
||||||
|
|
||||||
|
The various errors returned by this module are described in the
|
||||||
|
[errors section](#errors).
|
||||||
|
|
||||||
|
### bodyParser.json([options])
|
||||||
|
|
||||||
|
Returns middleware that only parses `json` and only looks at requests where
|
||||||
|
the `Content-Type` header matches the `type` option. This parser accepts any
|
||||||
|
Unicode encoding of the body and supports automatic inflation of `gzip` and
|
||||||
|
`deflate` encodings.
|
||||||
|
|
||||||
|
A new `body` object containing the parsed data is populated on the `request`
|
||||||
|
object after the middleware (i.e. `req.body`).
|
||||||
|
|
||||||
|
#### Options
|
||||||
|
|
||||||
|
The `json` function takes an optional `options` object that may contain any of
|
||||||
|
the following keys:
|
||||||
|
|
||||||
|
##### inflate
|
||||||
|
|
||||||
|
When set to `true`, then deflated (compressed) bodies will be inflated; when
|
||||||
|
`false`, deflated bodies are rejected. Defaults to `true`.
|
||||||
|
|
||||||
|
##### limit
|
||||||
|
|
||||||
|
Controls the maximum request body size. If this is a number, then the value
|
||||||
|
specifies the number of bytes; if it is a string, the value is passed to the
|
||||||
|
[bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults
|
||||||
|
to `'100kb'`.
|
||||||
|
|
||||||
|
##### reviver
|
||||||
|
|
||||||
|
The `reviver` option is passed directly to `JSON.parse` as the second
|
||||||
|
argument. You can find more information on this argument
|
||||||
|
[in the MDN documentation about JSON.parse](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter).
|
||||||
|
|
||||||
|
##### strict
|
||||||
|
|
||||||
|
When set to `true`, will only accept arrays and objects; when `false` will
|
||||||
|
accept anything `JSON.parse` accepts. Defaults to `true`.
|
||||||
|
|
||||||
|
##### type
|
||||||
|
|
||||||
|
The `type` option is used to determine what media type the middleware will
|
||||||
|
parse. This option can be a string, array of strings, or a function. If not a
|
||||||
|
function, `type` option is passed directly to the
|
||||||
|
[type-is](https://www.npmjs.org/package/type-is#readme) library and this can
|
||||||
|
be an extension name (like `json`), a mime type (like `application/json`), or
|
||||||
|
a mime type with a wildcard (like `*/*` or `*/json`). If a function, the `type`
|
||||||
|
option is called as `fn(req)` and the request is parsed if it returns a truthy
|
||||||
|
value. Defaults to `application/json`.
|
||||||
|
|
||||||
|
##### verify
|
||||||
|
|
||||||
|
The `verify` option, if supplied, is called as `verify(req, res, buf, encoding)`,
|
||||||
|
where `buf` is a `Buffer` of the raw request body and `encoding` is the
|
||||||
|
encoding of the request. The parsing can be aborted by throwing an error.
|
||||||
|
|
||||||
|
### bodyParser.raw([options])
|
||||||
|
|
||||||
|
Returns middleware that parses all bodies as a `Buffer` and only looks at
|
||||||
|
requests where the `Content-Type` header matches the `type` option. This
|
||||||
|
parser supports automatic inflation of `gzip` and `deflate` encodings.
|
||||||
|
|
||||||
|
A new `body` object containing the parsed data is populated on the `request`
|
||||||
|
object after the middleware (i.e. `req.body`). This will be a `Buffer` object
|
||||||
|
of the body.
|
||||||
|
|
||||||
|
#### Options
|
||||||
|
|
||||||
|
The `raw` function takes an optional `options` object that may contain any of
|
||||||
|
the following keys:
|
||||||
|
|
||||||
|
##### inflate
|
||||||
|
|
||||||
|
When set to `true`, then deflated (compressed) bodies will be inflated; when
|
||||||
|
`false`, deflated bodies are rejected. Defaults to `true`.
|
||||||
|
|
||||||
|
##### limit
|
||||||
|
|
||||||
|
Controls the maximum request body size. If this is a number, then the value
|
||||||
|
specifies the number of bytes; if it is a string, the value is passed to the
|
||||||
|
[bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults
|
||||||
|
to `'100kb'`.
|
||||||
|
|
||||||
|
##### type
|
||||||
|
|
||||||
|
The `type` option is used to determine what media type the middleware will
|
||||||
|
parse. This option can be a string, array of strings, or a function.
|
||||||
|
If not a function, `type` option is passed directly to the
|
||||||
|
[type-is](https://www.npmjs.org/package/type-is#readme) library and this
|
||||||
|
can be an extension name (like `bin`), a mime type (like
|
||||||
|
`application/octet-stream`), or a mime type with a wildcard (like `*/*` or
|
||||||
|
`application/*`). If a function, the `type` option is called as `fn(req)`
|
||||||
|
and the request is parsed if it returns a truthy value. Defaults to
|
||||||
|
`application/octet-stream`.
|
||||||
|
|
||||||
|
##### verify
|
||||||
|
|
||||||
|
The `verify` option, if supplied, is called as `verify(req, res, buf, encoding)`,
|
||||||
|
where `buf` is a `Buffer` of the raw request body and `encoding` is the
|
||||||
|
encoding of the request. The parsing can be aborted by throwing an error.
|
||||||
|
|
||||||
|
### bodyParser.text([options])
|
||||||
|
|
||||||
|
Returns middleware that parses all bodies as a string and only looks at
|
||||||
|
requests where the `Content-Type` header matches the `type` option. This
|
||||||
|
parser supports automatic inflation of `gzip` and `deflate` encodings.
|
||||||
|
|
||||||
|
A new `body` string containing the parsed data is populated on the `request`
|
||||||
|
object after the middleware (i.e. `req.body`). This will be a string of the
|
||||||
|
body.
|
||||||
|
|
||||||
|
#### Options
|
||||||
|
|
||||||
|
The `text` function takes an optional `options` object that may contain any of
|
||||||
|
the following keys:
|
||||||
|
|
||||||
|
##### defaultCharset
|
||||||
|
|
||||||
|
Specify the default character set for the text content if the charset is not
|
||||||
|
specified in the `Content-Type` header of the request. Defaults to `utf-8`.
|
||||||
|
|
||||||
|
##### inflate
|
||||||
|
|
||||||
|
When set to `true`, then deflated (compressed) bodies will be inflated; when
|
||||||
|
`false`, deflated bodies are rejected. Defaults to `true`.
|
||||||
|
|
||||||
|
##### limit
|
||||||
|
|
||||||
|
Controls the maximum request body size. If this is a number, then the value
|
||||||
|
specifies the number of bytes; if it is a string, the value is passed to the
|
||||||
|
[bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults
|
||||||
|
to `'100kb'`.
|
||||||
|
|
||||||
|
##### type
|
||||||
|
|
||||||
|
The `type` option is used to determine what media type the middleware will
|
||||||
|
parse. This option can be a string, array of strings, or a function. If not
|
||||||
|
a function, `type` option is passed directly to the
|
||||||
|
[type-is](https://www.npmjs.org/package/type-is#readme) library and this can
|
||||||
|
be an extension name (like `txt`), a mime type (like `text/plain`), or a mime
|
||||||
|
type with a wildcard (like `*/*` or `text/*`). If a function, the `type`
|
||||||
|
option is called as `fn(req)` and the request is parsed if it returns a
|
||||||
|
truthy value. Defaults to `text/plain`.
|
||||||
|
|
||||||
|
##### verify
|
||||||
|
|
||||||
|
The `verify` option, if supplied, is called as `verify(req, res, buf, encoding)`,
|
||||||
|
where `buf` is a `Buffer` of the raw request body and `encoding` is the
|
||||||
|
encoding of the request. The parsing can be aborted by throwing an error.
|
||||||
|
|
||||||
|
### bodyParser.urlencoded([options])
|
||||||
|
|
||||||
|
Returns middleware that only parses `urlencoded` bodies and only looks at
|
||||||
|
requests where the `Content-Type` header matches the `type` option. This
|
||||||
|
parser accepts only UTF-8 encoding of the body and supports automatic
|
||||||
|
inflation of `gzip` and `deflate` encodings.
|
||||||
|
|
||||||
|
A new `body` object containing the parsed data is populated on the `request`
|
||||||
|
object after the middleware (i.e. `req.body`). This object will contain
|
||||||
|
key-value pairs, where the value can be a string or array (when `extended` is
|
||||||
|
`false`), or any type (when `extended` is `true`).
|
||||||
|
|
||||||
|
#### Options
|
||||||
|
|
||||||
|
The `urlencoded` function takes an optional `options` object that may contain
|
||||||
|
any of the following keys:
|
||||||
|
|
||||||
|
##### extended
|
||||||
|
|
||||||
|
The `extended` option allows to choose between parsing the URL-encoded data
|
||||||
|
with the `querystring` library (when `false`) or the `qs` library (when
|
||||||
|
`true`). The "extended" syntax allows for rich objects and arrays to be
|
||||||
|
encoded into the URL-encoded format, allowing for a JSON-like experience
|
||||||
|
with URL-encoded. For more information, please
|
||||||
|
[see the qs library](https://www.npmjs.org/package/qs#readme).
|
||||||
|
|
||||||
|
Defaults to `true`, but using the default has been deprecated. Please
|
||||||
|
research into the difference between `qs` and `querystring` and choose the
|
||||||
|
appropriate setting.
|
||||||
|
|
||||||
|
##### inflate
|
||||||
|
|
||||||
|
When set to `true`, then deflated (compressed) bodies will be inflated; when
|
||||||
|
`false`, deflated bodies are rejected. Defaults to `true`.
|
||||||
|
|
||||||
|
##### limit
|
||||||
|
|
||||||
|
Controls the maximum request body size. If this is a number, then the value
|
||||||
|
specifies the number of bytes; if it is a string, the value is passed to the
|
||||||
|
[bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults
|
||||||
|
to `'100kb'`.
|
||||||
|
|
||||||
|
##### parameterLimit
|
||||||
|
|
||||||
|
The `parameterLimit` option controls the maximum number of parameters that
|
||||||
|
are allowed in the URL-encoded data. If a request contains more parameters
|
||||||
|
than this value, a 413 will be returned to the client. Defaults to `1000`.
|
||||||
|
|
||||||
|
##### type
|
||||||
|
|
||||||
|
The `type` option is used to determine what media type the middleware will
|
||||||
|
parse. This option can be a string, array of strings, or a function. If not
|
||||||
|
a function, `type` option is passed directly to the
|
||||||
|
[type-is](https://www.npmjs.org/package/type-is#readme) library and this can
|
||||||
|
be an extension name (like `urlencoded`), a mime type (like
|
||||||
|
`application/x-www-form-urlencoded`), or a mime type with a wildcard (like
|
||||||
|
`*/x-www-form-urlencoded`). If a function, the `type` option is called as
|
||||||
|
`fn(req)` and the request is parsed if it returns a truthy value. Defaults
|
||||||
|
to `application/x-www-form-urlencoded`.
|
||||||
|
|
||||||
|
##### verify
|
||||||
|
|
||||||
|
The `verify` option, if supplied, is called as `verify(req, res, buf, encoding)`,
|
||||||
|
where `buf` is a `Buffer` of the raw request body and `encoding` is the
|
||||||
|
encoding of the request. The parsing can be aborted by throwing an error.
|
||||||
|
|
||||||
|
#### depth
|
||||||
|
|
||||||
|
The `depth` option is used to configure the maximum depth of the `qs` library when `extended` is `true`. This allows you to limit the amount of keys that are parsed and can be useful to prevent certain types of abuse. Defaults to `32`. It is recommended to keep this value as low as possible.
|
||||||
|
|
||||||
|
## Errors
|
||||||
|
|
||||||
|
The middlewares provided by this module create errors using the
|
||||||
|
[`http-errors` module](https://www.npmjs.com/package/http-errors). The errors
|
||||||
|
will typically have a `status`/`statusCode` property that contains the suggested
|
||||||
|
HTTP response code, an `expose` property to determine if the `message` property
|
||||||
|
should be displayed to the client, a `type` property to determine the type of
|
||||||
|
error without matching against the `message`, and a `body` property containing
|
||||||
|
the read body, if available.
|
||||||
|
|
||||||
|
The following are the common errors created, though any error can come through
|
||||||
|
for various reasons.
|
||||||
|
|
||||||
|
### content encoding unsupported
|
||||||
|
|
||||||
|
This error will occur when the request had a `Content-Encoding` header that
|
||||||
|
contained an encoding but the "inflation" option was set to `false`. The
|
||||||
|
`status` property is set to `415`, the `type` property is set to
|
||||||
|
`'encoding.unsupported'`, and the `charset` property will be set to the
|
||||||
|
encoding that is unsupported.
|
||||||
|
|
||||||
|
### entity parse failed
|
||||||
|
|
||||||
|
This error will occur when the request contained an entity that could not be
|
||||||
|
parsed by the middleware. The `status` property is set to `400`, the `type`
|
||||||
|
property is set to `'entity.parse.failed'`, and the `body` property is set to
|
||||||
|
the entity value that failed parsing.
|
||||||
|
|
||||||
|
### entity verify failed
|
||||||
|
|
||||||
|
This error will occur when the request contained an entity that could not be
|
||||||
|
failed verification by the defined `verify` option. The `status` property is
|
||||||
|
set to `403`, the `type` property is set to `'entity.verify.failed'`, and the
|
||||||
|
`body` property is set to the entity value that failed verification.
|
||||||
|
|
||||||
|
### request aborted
|
||||||
|
|
||||||
|
This error will occur when the request is aborted by the client before reading
|
||||||
|
the body has finished. The `received` property will be set to the number of
|
||||||
|
bytes received before the request was aborted and the `expected` property is
|
||||||
|
set to the number of expected bytes. The `status` property is set to `400`
|
||||||
|
and `type` property is set to `'request.aborted'`.
|
||||||
|
|
||||||
|
### request entity too large
|
||||||
|
|
||||||
|
This error will occur when the request body's size is larger than the "limit"
|
||||||
|
option. The `limit` property will be set to the byte limit and the `length`
|
||||||
|
property will be set to the request body's length. The `status` property is
|
||||||
|
set to `413` and the `type` property is set to `'entity.too.large'`.
|
||||||
|
|
||||||
|
### request size did not match content length
|
||||||
|
|
||||||
|
This error will occur when the request's length did not match the length from
|
||||||
|
the `Content-Length` header. This typically occurs when the request is malformed,
|
||||||
|
typically when the `Content-Length` header was calculated based on characters
|
||||||
|
instead of bytes. The `status` property is set to `400` and the `type` property
|
||||||
|
is set to `'request.size.invalid'`.
|
||||||
|
|
||||||
|
### stream encoding should not be set
|
||||||
|
|
||||||
|
This error will occur when something called the `req.setEncoding` method prior
|
||||||
|
to this middleware. This module operates directly on bytes only and you cannot
|
||||||
|
call `req.setEncoding` when using this module. The `status` property is set to
|
||||||
|
`500` and the `type` property is set to `'stream.encoding.set'`.
|
||||||
|
|
||||||
|
### stream is not readable
|
||||||
|
|
||||||
|
This error will occur when the request is no longer readable when this middleware
|
||||||
|
attempts to read it. This typically means something other than a middleware from
|
||||||
|
this module read the request body already and the middleware was also configured to
|
||||||
|
read the same request. The `status` property is set to `500` and the `type`
|
||||||
|
property is set to `'stream.not.readable'`.
|
||||||
|
|
||||||
|
### too many parameters
|
||||||
|
|
||||||
|
This error will occur when the content of the request exceeds the configured
|
||||||
|
`parameterLimit` for the `urlencoded` parser. The `status` property is set to
|
||||||
|
`413` and the `type` property is set to `'parameters.too.many'`.
|
||||||
|
|
||||||
|
### unsupported charset "BOGUS"
|
||||||
|
|
||||||
|
This error will occur when the request had a charset parameter in the
|
||||||
|
`Content-Type` header, but the `iconv-lite` module does not support it OR the
|
||||||
|
parser does not support it. The charset is contained in the message as well
|
||||||
|
as in the `charset` property. The `status` property is set to `415`, the
|
||||||
|
`type` property is set to `'charset.unsupported'`, and the `charset` property
|
||||||
|
is set to the charset that is unsupported.
|
||||||
|
|
||||||
|
### unsupported content encoding "bogus"
|
||||||
|
|
||||||
|
This error will occur when the request had a `Content-Encoding` header that
|
||||||
|
contained an unsupported encoding. The encoding is contained in the message
|
||||||
|
as well as in the `encoding` property. The `status` property is set to `415`,
|
||||||
|
the `type` property is set to `'encoding.unsupported'`, and the `encoding`
|
||||||
|
property is set to the encoding that is unsupported.
|
||||||
|
|
||||||
|
### The input exceeded the depth
|
||||||
|
|
||||||
|
This error occurs when using `bodyParser.urlencoded` with the `extended` property set to `true` and the input exceeds the configured `depth` option. The `status` property is set to `400`. It is recommended to review the `depth` option and evaluate if it requires a higher value. When the `depth` option is set to `32` (default value), the error will not be thrown.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Express/Connect top-level generic
|
||||||
|
|
||||||
|
This example demonstrates adding a generic JSON and URL-encoded parser as a
|
||||||
|
top-level middleware, which will parse the bodies of all incoming requests.
|
||||||
|
This is the simplest setup.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var express = require('express')
|
||||||
|
var bodyParser = require('body-parser')
|
||||||
|
|
||||||
|
var app = express()
|
||||||
|
|
||||||
|
// parse application/x-www-form-urlencoded
|
||||||
|
app.use(bodyParser.urlencoded({ extended: false }))
|
||||||
|
|
||||||
|
// parse application/json
|
||||||
|
app.use(bodyParser.json())
|
||||||
|
|
||||||
|
app.use(function (req, res) {
|
||||||
|
res.setHeader('Content-Type', 'text/plain')
|
||||||
|
res.write('you posted:\n')
|
||||||
|
res.end(JSON.stringify(req.body, null, 2))
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### Express route-specific
|
||||||
|
|
||||||
|
This example demonstrates adding body parsers specifically to the routes that
|
||||||
|
need them. In general, this is the most recommended way to use body-parser with
|
||||||
|
Express.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var express = require('express')
|
||||||
|
var bodyParser = require('body-parser')
|
||||||
|
|
||||||
|
var app = express()
|
||||||
|
|
||||||
|
// create application/json parser
|
||||||
|
var jsonParser = bodyParser.json()
|
||||||
|
|
||||||
|
// create application/x-www-form-urlencoded parser
|
||||||
|
var urlencodedParser = bodyParser.urlencoded({ extended: false })
|
||||||
|
|
||||||
|
// POST /login gets urlencoded bodies
|
||||||
|
app.post('/login', urlencodedParser, function (req, res) {
|
||||||
|
res.send('welcome, ' + req.body.username)
|
||||||
|
})
|
||||||
|
|
||||||
|
// POST /api/users gets JSON bodies
|
||||||
|
app.post('/api/users', jsonParser, function (req, res) {
|
||||||
|
// create user in req.body
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### Change accepted type for parsers
|
||||||
|
|
||||||
|
All the parsers accept a `type` option which allows you to change the
|
||||||
|
`Content-Type` that the middleware will parse.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var express = require('express')
|
||||||
|
var bodyParser = require('body-parser')
|
||||||
|
|
||||||
|
var app = express()
|
||||||
|
|
||||||
|
// parse various different custom JSON types as JSON
|
||||||
|
app.use(bodyParser.json({ type: 'application/*+json' }))
|
||||||
|
|
||||||
|
// parse some custom thing into a Buffer
|
||||||
|
app.use(bodyParser.raw({ type: 'application/vnd.custom-type' }))
|
||||||
|
|
||||||
|
// parse an HTML body into a string
|
||||||
|
app.use(bodyParser.text({ type: 'text/html' }))
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[MIT](LICENSE)
|
||||||
|
|
||||||
|
[ci-image]: https://badgen.net/github/checks/expressjs/body-parser/master?label=ci
|
||||||
|
[ci-url]: https://github.com/expressjs/body-parser/actions/workflows/ci.yml
|
||||||
|
[coveralls-image]: https://badgen.net/coveralls/c/github/expressjs/body-parser/master
|
||||||
|
[coveralls-url]: https://coveralls.io/r/expressjs/body-parser?branch=master
|
||||||
|
[node-version-image]: https://badgen.net/npm/node/body-parser
|
||||||
|
[node-version-url]: https://nodejs.org/en/download
|
||||||
|
[npm-downloads-image]: https://badgen.net/npm/dm/body-parser
|
||||||
|
[npm-url]: https://npmjs.org/package/body-parser
|
||||||
|
[npm-version-image]: https://badgen.net/npm/v/body-parser
|
||||||
|
[ossf-scorecard-badge]: https://api.scorecard.dev/projects/github.com/expressjs/body-parser/badge
|
||||||
|
[ossf-scorecard-visualizer]: https://ossf.github.io/scorecard-visualizer/#/projects/github.com/expressjs/body-parser
|
||||||
25
node_modules/body-parser/SECURITY.md
generated
vendored
Normal file
25
node_modules/body-parser/SECURITY.md
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Security Policies and Procedures
|
||||||
|
|
||||||
|
## Reporting a Bug
|
||||||
|
|
||||||
|
The Express team and community take all security bugs seriously. Thank you
|
||||||
|
for improving the security of Express. We appreciate your efforts and
|
||||||
|
responsible disclosure and will make every effort to acknowledge your
|
||||||
|
contributions.
|
||||||
|
|
||||||
|
Report security bugs by emailing the current owner(s) of `body-parser`. This
|
||||||
|
information can be found in the npm registry using the command
|
||||||
|
`npm owner ls body-parser`.
|
||||||
|
If unsure or unable to get the information from the above, open an issue
|
||||||
|
in the [project issue tracker](https://github.com/expressjs/body-parser/issues)
|
||||||
|
asking for the current contact information.
|
||||||
|
|
||||||
|
To ensure the timely response to your report, please ensure that the entirety
|
||||||
|
of the report is contained within the email body and not solely behind a web
|
||||||
|
link or an attachment.
|
||||||
|
|
||||||
|
At least one owner will acknowledge your email within 48 hours, and will send a
|
||||||
|
more detailed response within 48 hours indicating the next steps in handling
|
||||||
|
your report. After the initial reply to your report, the owners will
|
||||||
|
endeavor to keep you informed of the progress towards a fix and full
|
||||||
|
announcement, and may ask for additional information or guidance.
|
||||||
156
node_modules/body-parser/index.js
generated
vendored
Normal file
156
node_modules/body-parser/index.js
generated
vendored
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
/*!
|
||||||
|
* body-parser
|
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
var deprecate = require('depd')('body-parser')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache of loaded parsers.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
var parsers = Object.create(null)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef Parsers
|
||||||
|
* @type {function}
|
||||||
|
* @property {function} json
|
||||||
|
* @property {function} raw
|
||||||
|
* @property {function} text
|
||||||
|
* @property {function} urlencoded
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
* @type {Parsers}
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports = module.exports = deprecate.function(bodyParser,
|
||||||
|
'bodyParser: use individual json/urlencoded middlewares')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JSON parser.
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Object.defineProperty(exports, 'json', {
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
get: createParserGetter('json')
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Raw parser.
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Object.defineProperty(exports, 'raw', {
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
get: createParserGetter('raw')
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Text parser.
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Object.defineProperty(exports, 'text', {
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
get: createParserGetter('text')
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* URL-encoded parser.
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Object.defineProperty(exports, 'urlencoded', {
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
get: createParserGetter('urlencoded')
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a middleware to parse json and urlencoded bodies.
|
||||||
|
*
|
||||||
|
* @param {object} [options]
|
||||||
|
* @return {function}
|
||||||
|
* @deprecated
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function bodyParser (options) {
|
||||||
|
// use default type for parsers
|
||||||
|
var opts = Object.create(options || null, {
|
||||||
|
type: {
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
value: undefined,
|
||||||
|
writable: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
var _urlencoded = exports.urlencoded(opts)
|
||||||
|
var _json = exports.json(opts)
|
||||||
|
|
||||||
|
return function bodyParser (req, res, next) {
|
||||||
|
_json(req, res, function (err) {
|
||||||
|
if (err) return next(err)
|
||||||
|
_urlencoded(req, res, next)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a getter for loading a parser.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function createParserGetter (name) {
|
||||||
|
return function get () {
|
||||||
|
return loadParser(name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load a parser module.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function loadParser (parserName) {
|
||||||
|
var parser = parsers[parserName]
|
||||||
|
|
||||||
|
if (parser !== undefined) {
|
||||||
|
return parser
|
||||||
|
}
|
||||||
|
|
||||||
|
// this uses a switch for static require analysis
|
||||||
|
switch (parserName) {
|
||||||
|
case 'json':
|
||||||
|
parser = require('./lib/types/json')
|
||||||
|
break
|
||||||
|
case 'raw':
|
||||||
|
parser = require('./lib/types/raw')
|
||||||
|
break
|
||||||
|
case 'text':
|
||||||
|
parser = require('./lib/types/text')
|
||||||
|
break
|
||||||
|
case 'urlencoded':
|
||||||
|
parser = require('./lib/types/urlencoded')
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
// store to prevent invoking require()
|
||||||
|
return (parsers[parserName] = parser)
|
||||||
|
}
|
||||||
205
node_modules/body-parser/lib/read.js
generated
vendored
Normal file
205
node_modules/body-parser/lib/read.js
generated
vendored
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
/*!
|
||||||
|
* body-parser
|
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
var createError = require('http-errors')
|
||||||
|
var destroy = require('destroy')
|
||||||
|
var getBody = require('raw-body')
|
||||||
|
var iconv = require('iconv-lite')
|
||||||
|
var onFinished = require('on-finished')
|
||||||
|
var unpipe = require('unpipe')
|
||||||
|
var zlib = require('zlib')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = read
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read a request into a buffer and parse.
|
||||||
|
*
|
||||||
|
* @param {object} req
|
||||||
|
* @param {object} res
|
||||||
|
* @param {function} next
|
||||||
|
* @param {function} parse
|
||||||
|
* @param {function} debug
|
||||||
|
* @param {object} options
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function read (req, res, next, parse, debug, options) {
|
||||||
|
var length
|
||||||
|
var opts = options
|
||||||
|
var stream
|
||||||
|
|
||||||
|
// flag as parsed
|
||||||
|
req._body = true
|
||||||
|
|
||||||
|
// read options
|
||||||
|
var encoding = opts.encoding !== null
|
||||||
|
? opts.encoding
|
||||||
|
: null
|
||||||
|
var verify = opts.verify
|
||||||
|
|
||||||
|
try {
|
||||||
|
// get the content stream
|
||||||
|
stream = contentstream(req, debug, opts.inflate)
|
||||||
|
length = stream.length
|
||||||
|
stream.length = undefined
|
||||||
|
} catch (err) {
|
||||||
|
return next(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// set raw-body options
|
||||||
|
opts.length = length
|
||||||
|
opts.encoding = verify
|
||||||
|
? null
|
||||||
|
: encoding
|
||||||
|
|
||||||
|
// assert charset is supported
|
||||||
|
if (opts.encoding === null && encoding !== null && !iconv.encodingExists(encoding)) {
|
||||||
|
return next(createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {
|
||||||
|
charset: encoding.toLowerCase(),
|
||||||
|
type: 'charset.unsupported'
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
// read body
|
||||||
|
debug('read body')
|
||||||
|
getBody(stream, opts, function (error, body) {
|
||||||
|
if (error) {
|
||||||
|
var _error
|
||||||
|
|
||||||
|
if (error.type === 'encoding.unsupported') {
|
||||||
|
// echo back charset
|
||||||
|
_error = createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {
|
||||||
|
charset: encoding.toLowerCase(),
|
||||||
|
type: 'charset.unsupported'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
// set status code on error
|
||||||
|
_error = createError(400, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// unpipe from stream and destroy
|
||||||
|
if (stream !== req) {
|
||||||
|
unpipe(req)
|
||||||
|
destroy(stream, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// read off entire request
|
||||||
|
dump(req, function onfinished () {
|
||||||
|
next(createError(400, _error))
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// verify
|
||||||
|
if (verify) {
|
||||||
|
try {
|
||||||
|
debug('verify body')
|
||||||
|
verify(req, res, body, encoding)
|
||||||
|
} catch (err) {
|
||||||
|
next(createError(403, err, {
|
||||||
|
body: body,
|
||||||
|
type: err.type || 'entity.verify.failed'
|
||||||
|
}))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse
|
||||||
|
var str = body
|
||||||
|
try {
|
||||||
|
debug('parse body')
|
||||||
|
str = typeof body !== 'string' && encoding !== null
|
||||||
|
? iconv.decode(body, encoding)
|
||||||
|
: body
|
||||||
|
req.body = parse(str)
|
||||||
|
} catch (err) {
|
||||||
|
next(createError(400, err, {
|
||||||
|
body: str,
|
||||||
|
type: err.type || 'entity.parse.failed'
|
||||||
|
}))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
next()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the content stream of the request.
|
||||||
|
*
|
||||||
|
* @param {object} req
|
||||||
|
* @param {function} debug
|
||||||
|
* @param {boolean} [inflate=true]
|
||||||
|
* @return {object}
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function contentstream (req, debug, inflate) {
|
||||||
|
var encoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
|
||||||
|
var length = req.headers['content-length']
|
||||||
|
var stream
|
||||||
|
|
||||||
|
debug('content-encoding "%s"', encoding)
|
||||||
|
|
||||||
|
if (inflate === false && encoding !== 'identity') {
|
||||||
|
throw createError(415, 'content encoding unsupported', {
|
||||||
|
encoding: encoding,
|
||||||
|
type: 'encoding.unsupported'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (encoding) {
|
||||||
|
case 'deflate':
|
||||||
|
stream = zlib.createInflate()
|
||||||
|
debug('inflate body')
|
||||||
|
req.pipe(stream)
|
||||||
|
break
|
||||||
|
case 'gzip':
|
||||||
|
stream = zlib.createGunzip()
|
||||||
|
debug('gunzip body')
|
||||||
|
req.pipe(stream)
|
||||||
|
break
|
||||||
|
case 'identity':
|
||||||
|
stream = req
|
||||||
|
stream.length = length
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
throw createError(415, 'unsupported content encoding "' + encoding + '"', {
|
||||||
|
encoding: encoding,
|
||||||
|
type: 'encoding.unsupported'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return stream
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dump the contents of a request.
|
||||||
|
*
|
||||||
|
* @param {object} req
|
||||||
|
* @param {function} callback
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function dump (req, callback) {
|
||||||
|
if (onFinished.isFinished(req)) {
|
||||||
|
callback(null)
|
||||||
|
} else {
|
||||||
|
onFinished(req, callback)
|
||||||
|
req.resume()
|
||||||
|
}
|
||||||
|
}
|
||||||
247
node_modules/body-parser/lib/types/json.js
generated
vendored
Normal file
247
node_modules/body-parser/lib/types/json.js
generated
vendored
Normal file
@@ -0,0 +1,247 @@
|
|||||||
|
/*!
|
||||||
|
* body-parser
|
||||||
|
* Copyright(c) 2014 Jonathan Ong
|
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
var bytes = require('bytes')
|
||||||
|
var contentType = require('content-type')
|
||||||
|
var createError = require('http-errors')
|
||||||
|
var debug = require('debug')('body-parser:json')
|
||||||
|
var read = require('../read')
|
||||||
|
var typeis = require('type-is')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = json
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RegExp to match the first non-space in a string.
|
||||||
|
*
|
||||||
|
* Allowed whitespace is defined in RFC 7159:
|
||||||
|
*
|
||||||
|
* ws = *(
|
||||||
|
* %x20 / ; Space
|
||||||
|
* %x09 / ; Horizontal tab
|
||||||
|
* %x0A / ; Line feed or New line
|
||||||
|
* %x0D ) ; Carriage return
|
||||||
|
*/
|
||||||
|
|
||||||
|
var FIRST_CHAR_REGEXP = /^[\x20\x09\x0a\x0d]*([^\x20\x09\x0a\x0d])/ // eslint-disable-line no-control-regex
|
||||||
|
|
||||||
|
var JSON_SYNTAX_CHAR = '#'
|
||||||
|
var JSON_SYNTAX_REGEXP = /#+/g
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a middleware to parse JSON bodies.
|
||||||
|
*
|
||||||
|
* @param {object} [options]
|
||||||
|
* @return {function}
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function json (options) {
|
||||||
|
var opts = options || {}
|
||||||
|
|
||||||
|
var limit = typeof opts.limit !== 'number'
|
||||||
|
? bytes.parse(opts.limit || '100kb')
|
||||||
|
: opts.limit
|
||||||
|
var inflate = opts.inflate !== false
|
||||||
|
var reviver = opts.reviver
|
||||||
|
var strict = opts.strict !== false
|
||||||
|
var type = opts.type || 'application/json'
|
||||||
|
var verify = opts.verify || false
|
||||||
|
|
||||||
|
if (verify !== false && typeof verify !== 'function') {
|
||||||
|
throw new TypeError('option verify must be function')
|
||||||
|
}
|
||||||
|
|
||||||
|
// create the appropriate type checking function
|
||||||
|
var shouldParse = typeof type !== 'function'
|
||||||
|
? typeChecker(type)
|
||||||
|
: type
|
||||||
|
|
||||||
|
function parse (body) {
|
||||||
|
if (body.length === 0) {
|
||||||
|
// special-case empty json body, as it's a common client-side mistake
|
||||||
|
// TODO: maybe make this configurable or part of "strict" option
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strict) {
|
||||||
|
var first = firstchar(body)
|
||||||
|
|
||||||
|
if (first !== '{' && first !== '[') {
|
||||||
|
debug('strict violation')
|
||||||
|
throw createStrictSyntaxError(body, first)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
debug('parse json')
|
||||||
|
return JSON.parse(body, reviver)
|
||||||
|
} catch (e) {
|
||||||
|
throw normalizeJsonSyntaxError(e, {
|
||||||
|
message: e.message,
|
||||||
|
stack: e.stack
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return function jsonParser (req, res, next) {
|
||||||
|
if (req._body) {
|
||||||
|
debug('body already parsed')
|
||||||
|
next()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
req.body = req.body || {}
|
||||||
|
|
||||||
|
// skip requests without bodies
|
||||||
|
if (!typeis.hasBody(req)) {
|
||||||
|
debug('skip empty body')
|
||||||
|
next()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('content-type %j', req.headers['content-type'])
|
||||||
|
|
||||||
|
// determine if request should be parsed
|
||||||
|
if (!shouldParse(req)) {
|
||||||
|
debug('skip parsing')
|
||||||
|
next()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// assert charset per RFC 7159 sec 8.1
|
||||||
|
var charset = getCharset(req) || 'utf-8'
|
||||||
|
if (charset.slice(0, 4) !== 'utf-') {
|
||||||
|
debug('invalid charset')
|
||||||
|
next(createError(415, 'unsupported charset "' + charset.toUpperCase() + '"', {
|
||||||
|
charset: charset,
|
||||||
|
type: 'charset.unsupported'
|
||||||
|
}))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// read
|
||||||
|
read(req, res, next, parse, debug, {
|
||||||
|
encoding: charset,
|
||||||
|
inflate: inflate,
|
||||||
|
limit: limit,
|
||||||
|
verify: verify
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create strict violation syntax error matching native error.
|
||||||
|
*
|
||||||
|
* @param {string} str
|
||||||
|
* @param {string} char
|
||||||
|
* @return {Error}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function createStrictSyntaxError (str, char) {
|
||||||
|
var index = str.indexOf(char)
|
||||||
|
var partial = ''
|
||||||
|
|
||||||
|
if (index !== -1) {
|
||||||
|
partial = str.substring(0, index) + JSON_SYNTAX_CHAR
|
||||||
|
|
||||||
|
for (var i = index + 1; i < str.length; i++) {
|
||||||
|
partial += JSON_SYNTAX_CHAR
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSON.parse(partial); /* istanbul ignore next */ throw new SyntaxError('strict violation')
|
||||||
|
} catch (e) {
|
||||||
|
return normalizeJsonSyntaxError(e, {
|
||||||
|
message: e.message.replace(JSON_SYNTAX_REGEXP, function (placeholder) {
|
||||||
|
return str.substring(index, index + placeholder.length)
|
||||||
|
}),
|
||||||
|
stack: e.stack
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the first non-whitespace character in a string.
|
||||||
|
*
|
||||||
|
* @param {string} str
|
||||||
|
* @return {function}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function firstchar (str) {
|
||||||
|
var match = FIRST_CHAR_REGEXP.exec(str)
|
||||||
|
|
||||||
|
return match
|
||||||
|
? match[1]
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the charset of a request.
|
||||||
|
*
|
||||||
|
* @param {object} req
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getCharset (req) {
|
||||||
|
try {
|
||||||
|
return (contentType.parse(req).parameters.charset || '').toLowerCase()
|
||||||
|
} catch (e) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalize a SyntaxError for JSON.parse.
|
||||||
|
*
|
||||||
|
* @param {SyntaxError} error
|
||||||
|
* @param {object} obj
|
||||||
|
* @return {SyntaxError}
|
||||||
|
*/
|
||||||
|
|
||||||
|
function normalizeJsonSyntaxError (error, obj) {
|
||||||
|
var keys = Object.getOwnPropertyNames(error)
|
||||||
|
|
||||||
|
for (var i = 0; i < keys.length; i++) {
|
||||||
|
var key = keys[i]
|
||||||
|
if (key !== 'stack' && key !== 'message') {
|
||||||
|
delete error[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// replace stack before message for Node.js 0.10 and below
|
||||||
|
error.stack = obj.stack.replace(error.message, obj.message)
|
||||||
|
error.message = obj.message
|
||||||
|
|
||||||
|
return error
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the simple type checker.
|
||||||
|
*
|
||||||
|
* @param {string} type
|
||||||
|
* @return {function}
|
||||||
|
*/
|
||||||
|
|
||||||
|
function typeChecker (type) {
|
||||||
|
return function checkType (req) {
|
||||||
|
return Boolean(typeis(req, type))
|
||||||
|
}
|
||||||
|
}
|
||||||
101
node_modules/body-parser/lib/types/raw.js
generated
vendored
Normal file
101
node_modules/body-parser/lib/types/raw.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
/*!
|
||||||
|
* body-parser
|
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var bytes = require('bytes')
|
||||||
|
var debug = require('debug')('body-parser:raw')
|
||||||
|
var read = require('../read')
|
||||||
|
var typeis = require('type-is')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = raw
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a middleware to parse raw bodies.
|
||||||
|
*
|
||||||
|
* @param {object} [options]
|
||||||
|
* @return {function}
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function raw (options) {
|
||||||
|
var opts = options || {}
|
||||||
|
|
||||||
|
var inflate = opts.inflate !== false
|
||||||
|
var limit = typeof opts.limit !== 'number'
|
||||||
|
? bytes.parse(opts.limit || '100kb')
|
||||||
|
: opts.limit
|
||||||
|
var type = opts.type || 'application/octet-stream'
|
||||||
|
var verify = opts.verify || false
|
||||||
|
|
||||||
|
if (verify !== false && typeof verify !== 'function') {
|
||||||
|
throw new TypeError('option verify must be function')
|
||||||
|
}
|
||||||
|
|
||||||
|
// create the appropriate type checking function
|
||||||
|
var shouldParse = typeof type !== 'function'
|
||||||
|
? typeChecker(type)
|
||||||
|
: type
|
||||||
|
|
||||||
|
function parse (buf) {
|
||||||
|
return buf
|
||||||
|
}
|
||||||
|
|
||||||
|
return function rawParser (req, res, next) {
|
||||||
|
if (req._body) {
|
||||||
|
debug('body already parsed')
|
||||||
|
next()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
req.body = req.body || {}
|
||||||
|
|
||||||
|
// skip requests without bodies
|
||||||
|
if (!typeis.hasBody(req)) {
|
||||||
|
debug('skip empty body')
|
||||||
|
next()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('content-type %j', req.headers['content-type'])
|
||||||
|
|
||||||
|
// determine if request should be parsed
|
||||||
|
if (!shouldParse(req)) {
|
||||||
|
debug('skip parsing')
|
||||||
|
next()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// read
|
||||||
|
read(req, res, next, parse, debug, {
|
||||||
|
encoding: null,
|
||||||
|
inflate: inflate,
|
||||||
|
limit: limit,
|
||||||
|
verify: verify
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the simple type checker.
|
||||||
|
*
|
||||||
|
* @param {string} type
|
||||||
|
* @return {function}
|
||||||
|
*/
|
||||||
|
|
||||||
|
function typeChecker (type) {
|
||||||
|
return function checkType (req) {
|
||||||
|
return Boolean(typeis(req, type))
|
||||||
|
}
|
||||||
|
}
|
||||||
121
node_modules/body-parser/lib/types/text.js
generated
vendored
Normal file
121
node_modules/body-parser/lib/types/text.js
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
/*!
|
||||||
|
* body-parser
|
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var bytes = require('bytes')
|
||||||
|
var contentType = require('content-type')
|
||||||
|
var debug = require('debug')('body-parser:text')
|
||||||
|
var read = require('../read')
|
||||||
|
var typeis = require('type-is')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = text
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a middleware to parse text bodies.
|
||||||
|
*
|
||||||
|
* @param {object} [options]
|
||||||
|
* @return {function}
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function text (options) {
|
||||||
|
var opts = options || {}
|
||||||
|
|
||||||
|
var defaultCharset = opts.defaultCharset || 'utf-8'
|
||||||
|
var inflate = opts.inflate !== false
|
||||||
|
var limit = typeof opts.limit !== 'number'
|
||||||
|
? bytes.parse(opts.limit || '100kb')
|
||||||
|
: opts.limit
|
||||||
|
var type = opts.type || 'text/plain'
|
||||||
|
var verify = opts.verify || false
|
||||||
|
|
||||||
|
if (verify !== false && typeof verify !== 'function') {
|
||||||
|
throw new TypeError('option verify must be function')
|
||||||
|
}
|
||||||
|
|
||||||
|
// create the appropriate type checking function
|
||||||
|
var shouldParse = typeof type !== 'function'
|
||||||
|
? typeChecker(type)
|
||||||
|
: type
|
||||||
|
|
||||||
|
function parse (buf) {
|
||||||
|
return buf
|
||||||
|
}
|
||||||
|
|
||||||
|
return function textParser (req, res, next) {
|
||||||
|
if (req._body) {
|
||||||
|
debug('body already parsed')
|
||||||
|
next()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
req.body = req.body || {}
|
||||||
|
|
||||||
|
// skip requests without bodies
|
||||||
|
if (!typeis.hasBody(req)) {
|
||||||
|
debug('skip empty body')
|
||||||
|
next()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('content-type %j', req.headers['content-type'])
|
||||||
|
|
||||||
|
// determine if request should be parsed
|
||||||
|
if (!shouldParse(req)) {
|
||||||
|
debug('skip parsing')
|
||||||
|
next()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// get charset
|
||||||
|
var charset = getCharset(req) || defaultCharset
|
||||||
|
|
||||||
|
// read
|
||||||
|
read(req, res, next, parse, debug, {
|
||||||
|
encoding: charset,
|
||||||
|
inflate: inflate,
|
||||||
|
limit: limit,
|
||||||
|
verify: verify
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the charset of a request.
|
||||||
|
*
|
||||||
|
* @param {object} req
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getCharset (req) {
|
||||||
|
try {
|
||||||
|
return (contentType.parse(req).parameters.charset || '').toLowerCase()
|
||||||
|
} catch (e) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the simple type checker.
|
||||||
|
*
|
||||||
|
* @param {string} type
|
||||||
|
* @return {function}
|
||||||
|
*/
|
||||||
|
|
||||||
|
function typeChecker (type) {
|
||||||
|
return function checkType (req) {
|
||||||
|
return Boolean(typeis(req, type))
|
||||||
|
}
|
||||||
|
}
|
||||||
307
node_modules/body-parser/lib/types/urlencoded.js
generated
vendored
Normal file
307
node_modules/body-parser/lib/types/urlencoded.js
generated
vendored
Normal file
@@ -0,0 +1,307 @@
|
|||||||
|
/*!
|
||||||
|
* body-parser
|
||||||
|
* Copyright(c) 2014 Jonathan Ong
|
||||||
|
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
var bytes = require('bytes')
|
||||||
|
var contentType = require('content-type')
|
||||||
|
var createError = require('http-errors')
|
||||||
|
var debug = require('debug')('body-parser:urlencoded')
|
||||||
|
var deprecate = require('depd')('body-parser')
|
||||||
|
var read = require('../read')
|
||||||
|
var typeis = require('type-is')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = urlencoded
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache of parser modules.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var parsers = Object.create(null)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a middleware to parse urlencoded bodies.
|
||||||
|
*
|
||||||
|
* @param {object} [options]
|
||||||
|
* @return {function}
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function urlencoded (options) {
|
||||||
|
var opts = options || {}
|
||||||
|
|
||||||
|
// notice because option default will flip in next major
|
||||||
|
if (opts.extended === undefined) {
|
||||||
|
deprecate('undefined extended: provide extended option')
|
||||||
|
}
|
||||||
|
|
||||||
|
var extended = opts.extended !== false
|
||||||
|
var inflate = opts.inflate !== false
|
||||||
|
var limit = typeof opts.limit !== 'number'
|
||||||
|
? bytes.parse(opts.limit || '100kb')
|
||||||
|
: opts.limit
|
||||||
|
var type = opts.type || 'application/x-www-form-urlencoded'
|
||||||
|
var verify = opts.verify || false
|
||||||
|
var depth = typeof opts.depth !== 'number'
|
||||||
|
? Number(opts.depth || 32)
|
||||||
|
: opts.depth
|
||||||
|
|
||||||
|
if (verify !== false && typeof verify !== 'function') {
|
||||||
|
throw new TypeError('option verify must be function')
|
||||||
|
}
|
||||||
|
|
||||||
|
// create the appropriate query parser
|
||||||
|
var queryparse = extended
|
||||||
|
? extendedparser(opts)
|
||||||
|
: simpleparser(opts)
|
||||||
|
|
||||||
|
// create the appropriate type checking function
|
||||||
|
var shouldParse = typeof type !== 'function'
|
||||||
|
? typeChecker(type)
|
||||||
|
: type
|
||||||
|
|
||||||
|
function parse (body) {
|
||||||
|
return body.length
|
||||||
|
? queryparse(body)
|
||||||
|
: {}
|
||||||
|
}
|
||||||
|
|
||||||
|
return function urlencodedParser (req, res, next) {
|
||||||
|
if (req._body) {
|
||||||
|
debug('body already parsed')
|
||||||
|
next()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
req.body = req.body || {}
|
||||||
|
|
||||||
|
// skip requests without bodies
|
||||||
|
if (!typeis.hasBody(req)) {
|
||||||
|
debug('skip empty body')
|
||||||
|
next()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('content-type %j', req.headers['content-type'])
|
||||||
|
|
||||||
|
// determine if request should be parsed
|
||||||
|
if (!shouldParse(req)) {
|
||||||
|
debug('skip parsing')
|
||||||
|
next()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// assert charset
|
||||||
|
var charset = getCharset(req) || 'utf-8'
|
||||||
|
if (charset !== 'utf-8') {
|
||||||
|
debug('invalid charset')
|
||||||
|
next(createError(415, 'unsupported charset "' + charset.toUpperCase() + '"', {
|
||||||
|
charset: charset,
|
||||||
|
type: 'charset.unsupported'
|
||||||
|
}))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// read
|
||||||
|
read(req, res, next, parse, debug, {
|
||||||
|
debug: debug,
|
||||||
|
encoding: charset,
|
||||||
|
inflate: inflate,
|
||||||
|
limit: limit,
|
||||||
|
verify: verify,
|
||||||
|
depth: depth
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the extended query parser.
|
||||||
|
*
|
||||||
|
* @param {object} options
|
||||||
|
*/
|
||||||
|
|
||||||
|
function extendedparser (options) {
|
||||||
|
var parameterLimit = options.parameterLimit !== undefined
|
||||||
|
? options.parameterLimit
|
||||||
|
: 1000
|
||||||
|
|
||||||
|
var depth = typeof options.depth !== 'number'
|
||||||
|
? Number(options.depth || 32)
|
||||||
|
: options.depth
|
||||||
|
var parse = parser('qs')
|
||||||
|
|
||||||
|
if (isNaN(parameterLimit) || parameterLimit < 1) {
|
||||||
|
throw new TypeError('option parameterLimit must be a positive number')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isNaN(depth) || depth < 0) {
|
||||||
|
throw new TypeError('option depth must be a zero or a positive number')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isFinite(parameterLimit)) {
|
||||||
|
parameterLimit = parameterLimit | 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return function queryparse (body) {
|
||||||
|
var paramCount = parameterCount(body, parameterLimit)
|
||||||
|
|
||||||
|
if (paramCount === undefined) {
|
||||||
|
debug('too many parameters')
|
||||||
|
throw createError(413, 'too many parameters', {
|
||||||
|
type: 'parameters.too.many'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
var arrayLimit = Math.max(100, paramCount)
|
||||||
|
|
||||||
|
debug('parse extended urlencoding')
|
||||||
|
try {
|
||||||
|
return parse(body, {
|
||||||
|
allowPrototypes: true,
|
||||||
|
arrayLimit: arrayLimit,
|
||||||
|
depth: depth,
|
||||||
|
strictDepth: true,
|
||||||
|
parameterLimit: parameterLimit
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
if (err instanceof RangeError) {
|
||||||
|
throw createError(400, 'The input exceeded the depth', {
|
||||||
|
type: 'querystring.parse.rangeError'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the charset of a request.
|
||||||
|
*
|
||||||
|
* @param {object} req
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getCharset (req) {
|
||||||
|
try {
|
||||||
|
return (contentType.parse(req).parameters.charset || '').toLowerCase()
|
||||||
|
} catch (e) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count the number of parameters, stopping once limit reached
|
||||||
|
*
|
||||||
|
* @param {string} body
|
||||||
|
* @param {number} limit
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function parameterCount (body, limit) {
|
||||||
|
var count = 0
|
||||||
|
var index = 0
|
||||||
|
|
||||||
|
while ((index = body.indexOf('&', index)) !== -1) {
|
||||||
|
count++
|
||||||
|
index++
|
||||||
|
|
||||||
|
if (count === limit) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get parser for module name dynamically.
|
||||||
|
*
|
||||||
|
* @param {string} name
|
||||||
|
* @return {function}
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function parser (name) {
|
||||||
|
var mod = parsers[name]
|
||||||
|
|
||||||
|
if (mod !== undefined) {
|
||||||
|
return mod.parse
|
||||||
|
}
|
||||||
|
|
||||||
|
// this uses a switch for static require analysis
|
||||||
|
switch (name) {
|
||||||
|
case 'qs':
|
||||||
|
mod = require('qs')
|
||||||
|
break
|
||||||
|
case 'querystring':
|
||||||
|
mod = require('querystring')
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
// store to prevent invoking require()
|
||||||
|
parsers[name] = mod
|
||||||
|
|
||||||
|
return mod.parse
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the simple query parser.
|
||||||
|
*
|
||||||
|
* @param {object} options
|
||||||
|
*/
|
||||||
|
|
||||||
|
function simpleparser (options) {
|
||||||
|
var parameterLimit = options.parameterLimit !== undefined
|
||||||
|
? options.parameterLimit
|
||||||
|
: 1000
|
||||||
|
var parse = parser('querystring')
|
||||||
|
|
||||||
|
if (isNaN(parameterLimit) || parameterLimit < 1) {
|
||||||
|
throw new TypeError('option parameterLimit must be a positive number')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isFinite(parameterLimit)) {
|
||||||
|
parameterLimit = parameterLimit | 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return function queryparse (body) {
|
||||||
|
var paramCount = parameterCount(body, parameterLimit)
|
||||||
|
|
||||||
|
if (paramCount === undefined) {
|
||||||
|
debug('too many parameters')
|
||||||
|
throw createError(413, 'too many parameters', {
|
||||||
|
type: 'parameters.too.many'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
debug('parse urlencoding')
|
||||||
|
return parse(body, undefined, undefined, { maxKeys: parameterLimit })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the simple type checker.
|
||||||
|
*
|
||||||
|
* @param {string} type
|
||||||
|
* @return {function}
|
||||||
|
*/
|
||||||
|
|
||||||
|
function typeChecker (type) {
|
||||||
|
return function checkType (req) {
|
||||||
|
return Boolean(typeis(req, type))
|
||||||
|
}
|
||||||
|
}
|
||||||
56
node_modules/body-parser/package.json
generated
vendored
Normal file
56
node_modules/body-parser/package.json
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
"name": "body-parser",
|
||||||
|
"description": "Node.js body parsing middleware",
|
||||||
|
"version": "1.20.3",
|
||||||
|
"contributors": [
|
||||||
|
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||||
|
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "expressjs/body-parser",
|
||||||
|
"dependencies": {
|
||||||
|
"bytes": "3.1.2",
|
||||||
|
"content-type": "~1.0.5",
|
||||||
|
"debug": "2.6.9",
|
||||||
|
"depd": "2.0.0",
|
||||||
|
"destroy": "1.2.0",
|
||||||
|
"http-errors": "2.0.0",
|
||||||
|
"iconv-lite": "0.4.24",
|
||||||
|
"on-finished": "2.4.1",
|
||||||
|
"qs": "6.13.0",
|
||||||
|
"raw-body": "2.5.2",
|
||||||
|
"type-is": "~1.6.18",
|
||||||
|
"unpipe": "1.0.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"eslint": "8.34.0",
|
||||||
|
"eslint-config-standard": "14.1.1",
|
||||||
|
"eslint-plugin-import": "2.27.5",
|
||||||
|
"eslint-plugin-markdown": "3.0.0",
|
||||||
|
"eslint-plugin-node": "11.1.0",
|
||||||
|
"eslint-plugin-promise": "6.1.1",
|
||||||
|
"eslint-plugin-standard": "4.1.0",
|
||||||
|
"methods": "1.1.2",
|
||||||
|
"mocha": "10.2.0",
|
||||||
|
"nyc": "15.1.0",
|
||||||
|
"safe-buffer": "5.2.1",
|
||||||
|
"supertest": "6.3.3"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"lib/",
|
||||||
|
"LICENSE",
|
||||||
|
"HISTORY.md",
|
||||||
|
"SECURITY.md",
|
||||||
|
"index.js"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.8",
|
||||||
|
"npm": "1.2.8000 || >= 1.4.16"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"lint": "eslint .",
|
||||||
|
"test": "mocha --require test/support/env --reporter spec --check-leaks --bail test/",
|
||||||
|
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
||||||
|
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
||||||
|
}
|
||||||
|
}
|
||||||
21
node_modules/brace-expansion/LICENSE
generated
vendored
Normal file
21
node_modules/brace-expansion/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
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.
|
||||||
129
node_modules/brace-expansion/README.md
generated
vendored
Normal file
129
node_modules/brace-expansion/README.md
generated
vendored
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
# brace-expansion
|
||||||
|
|
||||||
|
[Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html),
|
||||||
|
as known from sh/bash, in JavaScript.
|
||||||
|
|
||||||
|
[](http://travis-ci.org/juliangruber/brace-expansion)
|
||||||
|
[](https://www.npmjs.org/package/brace-expansion)
|
||||||
|
[](https://greenkeeper.io/)
|
||||||
|
|
||||||
|
[](https://ci.testling.com/juliangruber/brace-expansion)
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```js
|
||||||
|
var expand = require('brace-expansion');
|
||||||
|
|
||||||
|
expand('file-{a,b,c}.jpg')
|
||||||
|
// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
|
||||||
|
|
||||||
|
expand('-v{,,}')
|
||||||
|
// => ['-v', '-v', '-v']
|
||||||
|
|
||||||
|
expand('file{0..2}.jpg')
|
||||||
|
// => ['file0.jpg', 'file1.jpg', 'file2.jpg']
|
||||||
|
|
||||||
|
expand('file-{a..c}.jpg')
|
||||||
|
// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
|
||||||
|
|
||||||
|
expand('file{2..0}.jpg')
|
||||||
|
// => ['file2.jpg', 'file1.jpg', 'file0.jpg']
|
||||||
|
|
||||||
|
expand('file{0..4..2}.jpg')
|
||||||
|
// => ['file0.jpg', 'file2.jpg', 'file4.jpg']
|
||||||
|
|
||||||
|
expand('file-{a..e..2}.jpg')
|
||||||
|
// => ['file-a.jpg', 'file-c.jpg', 'file-e.jpg']
|
||||||
|
|
||||||
|
expand('file{00..10..5}.jpg')
|
||||||
|
// => ['file00.jpg', 'file05.jpg', 'file10.jpg']
|
||||||
|
|
||||||
|
expand('{{A..C},{a..c}}')
|
||||||
|
// => ['A', 'B', 'C', 'a', 'b', 'c']
|
||||||
|
|
||||||
|
expand('ppp{,config,oe{,conf}}')
|
||||||
|
// => ['ppp', 'pppconfig', 'pppoe', 'pppoeconf']
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
```js
|
||||||
|
var expand = require('brace-expansion');
|
||||||
|
```
|
||||||
|
|
||||||
|
### var expanded = expand(str)
|
||||||
|
|
||||||
|
Return an array of all possible and valid expansions of `str`. If none are
|
||||||
|
found, `[str]` is returned.
|
||||||
|
|
||||||
|
Valid expansions are:
|
||||||
|
|
||||||
|
```js
|
||||||
|
/^(.*,)+(.+)?$/
|
||||||
|
// {a,b,...}
|
||||||
|
```
|
||||||
|
|
||||||
|
A comma separated list of options, like `{a,b}` or `{a,{b,c}}` or `{,a,}`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
|
||||||
|
// {x..y[..incr]}
|
||||||
|
```
|
||||||
|
|
||||||
|
A numeric sequence from `x` to `y` inclusive, with optional increment.
|
||||||
|
If `x` or `y` start with a leading `0`, all the numbers will be padded
|
||||||
|
to have equal length. Negative numbers and backwards iteration work too.
|
||||||
|
|
||||||
|
```js
|
||||||
|
/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
|
||||||
|
// {x..y[..incr]}
|
||||||
|
```
|
||||||
|
|
||||||
|
An alphabetic sequence from `x` to `y` inclusive, with optional increment.
|
||||||
|
`x` and `y` must be exactly one character, and if given, `incr` must be a
|
||||||
|
number.
|
||||||
|
|
||||||
|
For compatibility reasons, the string `${` is not eligible for brace expansion.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
With [npm](https://npmjs.org) do:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install brace-expansion
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contributors
|
||||||
|
|
||||||
|
- [Julian Gruber](https://github.com/juliangruber)
|
||||||
|
- [Isaac Z. Schlueter](https://github.com/isaacs)
|
||||||
|
|
||||||
|
## Sponsors
|
||||||
|
|
||||||
|
This module is proudly supported by my [Sponsors](https://github.com/juliangruber/sponsors)!
|
||||||
|
|
||||||
|
Do you want to support modules like this to improve their quality, stability and weigh in on new features? Then please consider donating to my [Patreon](https://www.patreon.com/juliangruber). Not sure how much of my modules you're using? Try [feross/thanks](https://github.com/feross/thanks)!
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
(MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
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.
|
||||||
201
node_modules/brace-expansion/index.js
generated
vendored
Normal file
201
node_modules/brace-expansion/index.js
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
var concatMap = require('concat-map');
|
||||||
|
var balanced = require('balanced-match');
|
||||||
|
|
||||||
|
module.exports = expandTop;
|
||||||
|
|
||||||
|
var escSlash = '\0SLASH'+Math.random()+'\0';
|
||||||
|
var escOpen = '\0OPEN'+Math.random()+'\0';
|
||||||
|
var escClose = '\0CLOSE'+Math.random()+'\0';
|
||||||
|
var escComma = '\0COMMA'+Math.random()+'\0';
|
||||||
|
var escPeriod = '\0PERIOD'+Math.random()+'\0';
|
||||||
|
|
||||||
|
function numeric(str) {
|
||||||
|
return parseInt(str, 10) == str
|
||||||
|
? parseInt(str, 10)
|
||||||
|
: str.charCodeAt(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function escapeBraces(str) {
|
||||||
|
return str.split('\\\\').join(escSlash)
|
||||||
|
.split('\\{').join(escOpen)
|
||||||
|
.split('\\}').join(escClose)
|
||||||
|
.split('\\,').join(escComma)
|
||||||
|
.split('\\.').join(escPeriod);
|
||||||
|
}
|
||||||
|
|
||||||
|
function unescapeBraces(str) {
|
||||||
|
return str.split(escSlash).join('\\')
|
||||||
|
.split(escOpen).join('{')
|
||||||
|
.split(escClose).join('}')
|
||||||
|
.split(escComma).join(',')
|
||||||
|
.split(escPeriod).join('.');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Basically just str.split(","), but handling cases
|
||||||
|
// where we have nested braced sections, which should be
|
||||||
|
// treated as individual members, like {a,{b,c},d}
|
||||||
|
function parseCommaParts(str) {
|
||||||
|
if (!str)
|
||||||
|
return [''];
|
||||||
|
|
||||||
|
var parts = [];
|
||||||
|
var m = balanced('{', '}', str);
|
||||||
|
|
||||||
|
if (!m)
|
||||||
|
return str.split(',');
|
||||||
|
|
||||||
|
var pre = m.pre;
|
||||||
|
var body = m.body;
|
||||||
|
var post = m.post;
|
||||||
|
var p = pre.split(',');
|
||||||
|
|
||||||
|
p[p.length-1] += '{' + body + '}';
|
||||||
|
var postParts = parseCommaParts(post);
|
||||||
|
if (post.length) {
|
||||||
|
p[p.length-1] += postParts.shift();
|
||||||
|
p.push.apply(p, postParts);
|
||||||
|
}
|
||||||
|
|
||||||
|
parts.push.apply(parts, p);
|
||||||
|
|
||||||
|
return parts;
|
||||||
|
}
|
||||||
|
|
||||||
|
function expandTop(str) {
|
||||||
|
if (!str)
|
||||||
|
return [];
|
||||||
|
|
||||||
|
// I don't know why Bash 4.3 does this, but it does.
|
||||||
|
// Anything starting with {} will have the first two bytes preserved
|
||||||
|
// but *only* at the top level, so {},a}b will not expand to anything,
|
||||||
|
// but a{},b}c will be expanded to [a}c,abc].
|
||||||
|
// One could argue that this is a bug in Bash, but since the goal of
|
||||||
|
// this module is to match Bash's rules, we escape a leading {}
|
||||||
|
if (str.substr(0, 2) === '{}') {
|
||||||
|
str = '\\{\\}' + str.substr(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return expand(escapeBraces(str), true).map(unescapeBraces);
|
||||||
|
}
|
||||||
|
|
||||||
|
function identity(e) {
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
function embrace(str) {
|
||||||
|
return '{' + str + '}';
|
||||||
|
}
|
||||||
|
function isPadded(el) {
|
||||||
|
return /^-?0\d/.test(el);
|
||||||
|
}
|
||||||
|
|
||||||
|
function lte(i, y) {
|
||||||
|
return i <= y;
|
||||||
|
}
|
||||||
|
function gte(i, y) {
|
||||||
|
return i >= y;
|
||||||
|
}
|
||||||
|
|
||||||
|
function expand(str, isTop) {
|
||||||
|
var expansions = [];
|
||||||
|
|
||||||
|
var m = balanced('{', '}', str);
|
||||||
|
if (!m || /\$$/.test(m.pre)) return [str];
|
||||||
|
|
||||||
|
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
||||||
|
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
||||||
|
var isSequence = isNumericSequence || isAlphaSequence;
|
||||||
|
var isOptions = m.body.indexOf(',') >= 0;
|
||||||
|
if (!isSequence && !isOptions) {
|
||||||
|
// {a},b}
|
||||||
|
if (m.post.match(/,.*\}/)) {
|
||||||
|
str = m.pre + '{' + m.body + escClose + m.post;
|
||||||
|
return expand(str);
|
||||||
|
}
|
||||||
|
return [str];
|
||||||
|
}
|
||||||
|
|
||||||
|
var n;
|
||||||
|
if (isSequence) {
|
||||||
|
n = m.body.split(/\.\./);
|
||||||
|
} else {
|
||||||
|
n = parseCommaParts(m.body);
|
||||||
|
if (n.length === 1) {
|
||||||
|
// x{{a,b}}y ==> x{a}y x{b}y
|
||||||
|
n = expand(n[0], false).map(embrace);
|
||||||
|
if (n.length === 1) {
|
||||||
|
var post = m.post.length
|
||||||
|
? expand(m.post, false)
|
||||||
|
: [''];
|
||||||
|
return post.map(function(p) {
|
||||||
|
return m.pre + n[0] + p;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// at this point, n is the parts, and we know it's not a comma set
|
||||||
|
// with a single entry.
|
||||||
|
|
||||||
|
// no need to expand pre, since it is guaranteed to be free of brace-sets
|
||||||
|
var pre = m.pre;
|
||||||
|
var post = m.post.length
|
||||||
|
? expand(m.post, false)
|
||||||
|
: [''];
|
||||||
|
|
||||||
|
var N;
|
||||||
|
|
||||||
|
if (isSequence) {
|
||||||
|
var x = numeric(n[0]);
|
||||||
|
var y = numeric(n[1]);
|
||||||
|
var width = Math.max(n[0].length, n[1].length)
|
||||||
|
var incr = n.length == 3
|
||||||
|
? Math.abs(numeric(n[2]))
|
||||||
|
: 1;
|
||||||
|
var test = lte;
|
||||||
|
var reverse = y < x;
|
||||||
|
if (reverse) {
|
||||||
|
incr *= -1;
|
||||||
|
test = gte;
|
||||||
|
}
|
||||||
|
var pad = n.some(isPadded);
|
||||||
|
|
||||||
|
N = [];
|
||||||
|
|
||||||
|
for (var i = x; test(i, y); i += incr) {
|
||||||
|
var c;
|
||||||
|
if (isAlphaSequence) {
|
||||||
|
c = String.fromCharCode(i);
|
||||||
|
if (c === '\\')
|
||||||
|
c = '';
|
||||||
|
} else {
|
||||||
|
c = String(i);
|
||||||
|
if (pad) {
|
||||||
|
var need = width - c.length;
|
||||||
|
if (need > 0) {
|
||||||
|
var z = new Array(need + 1).join('0');
|
||||||
|
if (i < 0)
|
||||||
|
c = '-' + z + c.slice(1);
|
||||||
|
else
|
||||||
|
c = z + c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
N.push(c);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
N = concatMap(n, function(el) { return expand(el, false) });
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var j = 0; j < N.length; j++) {
|
||||||
|
for (var k = 0; k < post.length; k++) {
|
||||||
|
var expansion = pre + N[j] + post[k];
|
||||||
|
if (!isTop || isSequence || expansion)
|
||||||
|
expansions.push(expansion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return expansions;
|
||||||
|
}
|
||||||
|
|
||||||
47
node_modules/brace-expansion/package.json
generated
vendored
Normal file
47
node_modules/brace-expansion/package.json
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"name": "brace-expansion",
|
||||||
|
"description": "Brace expansion as known from sh/bash",
|
||||||
|
"version": "1.1.11",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/juliangruber/brace-expansion.git"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/juliangruber/brace-expansion",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "tape test/*.js",
|
||||||
|
"gentest": "bash test/generate.sh",
|
||||||
|
"bench": "matcha test/perf/bench.js"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"balanced-match": "^1.0.0",
|
||||||
|
"concat-map": "0.0.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"matcha": "^0.7.0",
|
||||||
|
"tape": "^4.6.0"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": {
|
||||||
|
"name": "Julian Gruber",
|
||||||
|
"email": "mail@juliangruber.com",
|
||||||
|
"url": "http://juliangruber.com"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"testling": {
|
||||||
|
"files": "test/*.js",
|
||||||
|
"browsers": [
|
||||||
|
"ie/8..latest",
|
||||||
|
"firefox/20..latest",
|
||||||
|
"firefox/nightly",
|
||||||
|
"chrome/25..latest",
|
||||||
|
"chrome/canary",
|
||||||
|
"opera/12..latest",
|
||||||
|
"opera/next",
|
||||||
|
"safari/5.1..latest",
|
||||||
|
"ipad/6.0..latest",
|
||||||
|
"iphone/6.0..latest",
|
||||||
|
"android-browser/4.2..latest"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
21
node_modules/braces/LICENSE
generated
vendored
Normal file
21
node_modules/braces/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014-present, Jon Schlinkert.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
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.
|
||||||
586
node_modules/braces/README.md
generated
vendored
Normal file
586
node_modules/braces/README.md
generated
vendored
Normal file
@@ -0,0 +1,586 @@
|
|||||||
|
# braces [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=W8YFZ425KND68) [](https://www.npmjs.com/package/braces) [](https://npmjs.org/package/braces) [](https://npmjs.org/package/braces) [](https://travis-ci.org/micromatch/braces)
|
||||||
|
|
||||||
|
> Bash-like brace expansion, implemented in JavaScript. Safer than other brace expansion libs, with complete support for the Bash 4.3 braces specification, without sacrificing speed.
|
||||||
|
|
||||||
|
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
Install with [npm](https://www.npmjs.com/):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install --save braces
|
||||||
|
```
|
||||||
|
|
||||||
|
## v3.0.0 Released!!
|
||||||
|
|
||||||
|
See the [changelog](CHANGELOG.md) for details.
|
||||||
|
|
||||||
|
## Why use braces?
|
||||||
|
|
||||||
|
Brace patterns make globs more powerful by adding the ability to match specific ranges and sequences of characters.
|
||||||
|
|
||||||
|
- **Accurate** - complete support for the [Bash 4.3 Brace Expansion](www.gnu.org/software/bash/) specification (passes all of the Bash braces tests)
|
||||||
|
- **[fast and performant](#benchmarks)** - Starts fast, runs fast and [scales well](#performance) as patterns increase in complexity.
|
||||||
|
- **Organized code base** - The parser and compiler are easy to maintain and update when edge cases crop up.
|
||||||
|
- **Well-tested** - Thousands of test assertions, and passes all of the Bash, minimatch, and [brace-expansion](https://github.com/juliangruber/brace-expansion) unit tests (as of the date this was written).
|
||||||
|
- **Safer** - You shouldn't have to worry about users defining aggressive or malicious brace patterns that can break your application. Braces takes measures to prevent malicious regex that can be used for DDoS attacks (see [catastrophic backtracking](https://www.regular-expressions.info/catastrophic.html)).
|
||||||
|
- [Supports lists](#lists) - (aka "sets") `a/{b,c}/d` => `['a/b/d', 'a/c/d']`
|
||||||
|
- [Supports sequences](#sequences) - (aka "ranges") `{01..03}` => `['01', '02', '03']`
|
||||||
|
- [Supports steps](#steps) - (aka "increments") `{2..10..2}` => `['2', '4', '6', '8', '10']`
|
||||||
|
- [Supports escaping](#escaping) - To prevent evaluation of special characters.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
The main export is a function that takes one or more brace `patterns` and `options`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const braces = require('braces');
|
||||||
|
// braces(patterns[, options]);
|
||||||
|
|
||||||
|
console.log(braces(['{01..05}', '{a..e}']));
|
||||||
|
//=> ['(0[1-5])', '([a-e])']
|
||||||
|
|
||||||
|
console.log(braces(['{01..05}', '{a..e}'], { expand: true }));
|
||||||
|
//=> ['01', '02', '03', '04', '05', 'a', 'b', 'c', 'd', 'e']
|
||||||
|
```
|
||||||
|
|
||||||
|
### Brace Expansion vs. Compilation
|
||||||
|
|
||||||
|
By default, brace patterns are compiled into strings that are optimized for creating regular expressions and matching.
|
||||||
|
|
||||||
|
**Compiled**
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.log(braces('a/{x,y,z}/b'));
|
||||||
|
//=> ['a/(x|y|z)/b']
|
||||||
|
console.log(braces(['a/{01..20}/b', 'a/{1..5}/b']));
|
||||||
|
//=> [ 'a/(0[1-9]|1[0-9]|20)/b', 'a/([1-5])/b' ]
|
||||||
|
```
|
||||||
|
|
||||||
|
**Expanded**
|
||||||
|
|
||||||
|
Enable brace expansion by setting the `expand` option to true, or by using [braces.expand()](#expand) (returns an array similar to what you'd expect from Bash, or `echo {1..5}`, or [minimatch](https://github.com/isaacs/minimatch)):
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.log(braces('a/{x,y,z}/b', { expand: true }));
|
||||||
|
//=> ['a/x/b', 'a/y/b', 'a/z/b']
|
||||||
|
|
||||||
|
console.log(braces.expand('{01..10}'));
|
||||||
|
//=> ['01','02','03','04','05','06','07','08','09','10']
|
||||||
|
```
|
||||||
|
|
||||||
|
### Lists
|
||||||
|
|
||||||
|
Expand lists (like Bash "sets"):
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.log(braces('a/{foo,bar,baz}/*.js'));
|
||||||
|
//=> ['a/(foo|bar|baz)/*.js']
|
||||||
|
|
||||||
|
console.log(braces.expand('a/{foo,bar,baz}/*.js'));
|
||||||
|
//=> ['a/foo/*.js', 'a/bar/*.js', 'a/baz/*.js']
|
||||||
|
```
|
||||||
|
|
||||||
|
### Sequences
|
||||||
|
|
||||||
|
Expand ranges of characters (like Bash "sequences"):
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.log(braces.expand('{1..3}')); // ['1', '2', '3']
|
||||||
|
console.log(braces.expand('a/{1..3}/b')); // ['a/1/b', 'a/2/b', 'a/3/b']
|
||||||
|
console.log(braces('{a..c}', { expand: true })); // ['a', 'b', 'c']
|
||||||
|
console.log(braces('foo/{a..c}', { expand: true })); // ['foo/a', 'foo/b', 'foo/c']
|
||||||
|
|
||||||
|
// supports zero-padded ranges
|
||||||
|
console.log(braces('a/{01..03}/b')); //=> ['a/(0[1-3])/b']
|
||||||
|
console.log(braces('a/{001..300}/b')); //=> ['a/(0{2}[1-9]|0[1-9][0-9]|[12][0-9]{2}|300)/b']
|
||||||
|
```
|
||||||
|
|
||||||
|
See [fill-range](https://github.com/jonschlinkert/fill-range) for all available range-expansion options.
|
||||||
|
|
||||||
|
### Steppped ranges
|
||||||
|
|
||||||
|
Steps, or increments, may be used with ranges:
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.log(braces.expand('{2..10..2}'));
|
||||||
|
//=> ['2', '4', '6', '8', '10']
|
||||||
|
|
||||||
|
console.log(braces('{2..10..2}'));
|
||||||
|
//=> ['(2|4|6|8|10)']
|
||||||
|
```
|
||||||
|
|
||||||
|
When the [.optimize](#optimize) method is used, or [options.optimize](#optionsoptimize) is set to true, sequences are passed to [to-regex-range](https://github.com/jonschlinkert/to-regex-range) for expansion.
|
||||||
|
|
||||||
|
### Nesting
|
||||||
|
|
||||||
|
Brace patterns may be nested. The results of each expanded string are not sorted, and left to right order is preserved.
|
||||||
|
|
||||||
|
**"Expanded" braces**
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.log(braces.expand('a{b,c,/{x,y}}/e'));
|
||||||
|
//=> ['ab/e', 'ac/e', 'a/x/e', 'a/y/e']
|
||||||
|
|
||||||
|
console.log(braces.expand('a/{x,{1..5},y}/c'));
|
||||||
|
//=> ['a/x/c', 'a/1/c', 'a/2/c', 'a/3/c', 'a/4/c', 'a/5/c', 'a/y/c']
|
||||||
|
```
|
||||||
|
|
||||||
|
**"Optimized" braces**
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.log(braces('a{b,c,/{x,y}}/e'));
|
||||||
|
//=> ['a(b|c|/(x|y))/e']
|
||||||
|
|
||||||
|
console.log(braces('a/{x,{1..5},y}/c'));
|
||||||
|
//=> ['a/(x|([1-5])|y)/c']
|
||||||
|
```
|
||||||
|
|
||||||
|
### Escaping
|
||||||
|
|
||||||
|
**Escaping braces**
|
||||||
|
|
||||||
|
A brace pattern will not be expanded or evaluted if _either the opening or closing brace is escaped_:
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.log(braces.expand('a\\{d,c,b}e'));
|
||||||
|
//=> ['a{d,c,b}e']
|
||||||
|
|
||||||
|
console.log(braces.expand('a{d,c,b\\}e'));
|
||||||
|
//=> ['a{d,c,b}e']
|
||||||
|
```
|
||||||
|
|
||||||
|
**Escaping commas**
|
||||||
|
|
||||||
|
Commas inside braces may also be escaped:
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.log(braces.expand('a{b\\,c}d'));
|
||||||
|
//=> ['a{b,c}d']
|
||||||
|
|
||||||
|
console.log(braces.expand('a{d\\,c,b}e'));
|
||||||
|
//=> ['ad,ce', 'abe']
|
||||||
|
```
|
||||||
|
|
||||||
|
**Single items**
|
||||||
|
|
||||||
|
Following bash conventions, a brace pattern is also not expanded when it contains a single character:
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.log(braces.expand('a{b}c'));
|
||||||
|
//=> ['a{b}c']
|
||||||
|
```
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
|
### options.maxLength
|
||||||
|
|
||||||
|
**Type**: `Number`
|
||||||
|
|
||||||
|
**Default**: `10,000`
|
||||||
|
|
||||||
|
**Description**: Limit the length of the input string. Useful when the input string is generated or your application allows users to pass a string, et cetera.
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.log(braces('a/{b,c}/d', { maxLength: 3 })); //=> throws an error
|
||||||
|
```
|
||||||
|
|
||||||
|
### options.expand
|
||||||
|
|
||||||
|
**Type**: `Boolean`
|
||||||
|
|
||||||
|
**Default**: `undefined`
|
||||||
|
|
||||||
|
**Description**: Generate an "expanded" brace pattern (alternatively you can use the `braces.expand()` method, which does the same thing).
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.log(braces('a/{b,c}/d', { expand: true }));
|
||||||
|
//=> [ 'a/b/d', 'a/c/d' ]
|
||||||
|
```
|
||||||
|
|
||||||
|
### options.nodupes
|
||||||
|
|
||||||
|
**Type**: `Boolean`
|
||||||
|
|
||||||
|
**Default**: `undefined`
|
||||||
|
|
||||||
|
**Description**: Remove duplicates from the returned array.
|
||||||
|
|
||||||
|
### options.rangeLimit
|
||||||
|
|
||||||
|
**Type**: `Number`
|
||||||
|
|
||||||
|
**Default**: `1000`
|
||||||
|
|
||||||
|
**Description**: To prevent malicious patterns from being passed by users, an error is thrown when `braces.expand()` is used or `options.expand` is true and the generated range will exceed the `rangeLimit`.
|
||||||
|
|
||||||
|
You can customize `options.rangeLimit` or set it to `Inifinity` to disable this altogether.
|
||||||
|
|
||||||
|
**Examples**
|
||||||
|
|
||||||
|
```js
|
||||||
|
// pattern exceeds the "rangeLimit", so it's optimized automatically
|
||||||
|
console.log(braces.expand('{1..1000}'));
|
||||||
|
//=> ['([1-9]|[1-9][0-9]{1,2}|1000)']
|
||||||
|
|
||||||
|
// pattern does not exceed "rangeLimit", so it's NOT optimized
|
||||||
|
console.log(braces.expand('{1..100}'));
|
||||||
|
//=> ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '100']
|
||||||
|
```
|
||||||
|
|
||||||
|
### options.transform
|
||||||
|
|
||||||
|
**Type**: `Function`
|
||||||
|
|
||||||
|
**Default**: `undefined`
|
||||||
|
|
||||||
|
**Description**: Customize range expansion.
|
||||||
|
|
||||||
|
**Example: Transforming non-numeric values**
|
||||||
|
|
||||||
|
```js
|
||||||
|
const alpha = braces.expand('x/{a..e}/y', {
|
||||||
|
transform(value, index) {
|
||||||
|
// When non-numeric values are passed, "value" is a character code.
|
||||||
|
return 'foo/' + String.fromCharCode(value) + '-' + index;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
console.log(alpha);
|
||||||
|
//=> [ 'x/foo/a-0/y', 'x/foo/b-1/y', 'x/foo/c-2/y', 'x/foo/d-3/y', 'x/foo/e-4/y' ]
|
||||||
|
```
|
||||||
|
|
||||||
|
**Example: Transforming numeric values**
|
||||||
|
|
||||||
|
```js
|
||||||
|
const numeric = braces.expand('{1..5}', {
|
||||||
|
transform(value) {
|
||||||
|
// when numeric values are passed, "value" is a number
|
||||||
|
return 'foo/' + value * 2;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
console.log(numeric);
|
||||||
|
//=> [ 'foo/2', 'foo/4', 'foo/6', 'foo/8', 'foo/10' ]
|
||||||
|
```
|
||||||
|
|
||||||
|
### options.quantifiers
|
||||||
|
|
||||||
|
**Type**: `Boolean`
|
||||||
|
|
||||||
|
**Default**: `undefined`
|
||||||
|
|
||||||
|
**Description**: In regular expressions, quanitifiers can be used to specify how many times a token can be repeated. For example, `a{1,3}` will match the letter `a` one to three times.
|
||||||
|
|
||||||
|
Unfortunately, regex quantifiers happen to share the same syntax as [Bash lists](#lists)
|
||||||
|
|
||||||
|
The `quantifiers` option tells braces to detect when [regex quantifiers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#quantifiers) are defined in the given pattern, and not to try to expand them as lists.
|
||||||
|
|
||||||
|
**Examples**
|
||||||
|
|
||||||
|
```js
|
||||||
|
const braces = require('braces');
|
||||||
|
console.log(braces('a/b{1,3}/{x,y,z}'));
|
||||||
|
//=> [ 'a/b(1|3)/(x|y|z)' ]
|
||||||
|
console.log(braces('a/b{1,3}/{x,y,z}', { quantifiers: true }));
|
||||||
|
//=> [ 'a/b{1,3}/(x|y|z)' ]
|
||||||
|
console.log(braces('a/b{1,3}/{x,y,z}', { quantifiers: true, expand: true }));
|
||||||
|
//=> [ 'a/b{1,3}/x', 'a/b{1,3}/y', 'a/b{1,3}/z' ]
|
||||||
|
```
|
||||||
|
|
||||||
|
### options.keepEscaping
|
||||||
|
|
||||||
|
**Type**: `Boolean`
|
||||||
|
|
||||||
|
**Default**: `undefined`
|
||||||
|
|
||||||
|
**Description**: Do not strip backslashes that were used for escaping from the result.
|
||||||
|
|
||||||
|
## What is "brace expansion"?
|
||||||
|
|
||||||
|
Brace expansion is a type of parameter expansion that was made popular by unix shells for generating lists of strings, as well as regex-like matching when used alongside wildcards (globs).
|
||||||
|
|
||||||
|
In addition to "expansion", braces are also used for matching. In other words:
|
||||||
|
|
||||||
|
- [brace expansion](#brace-expansion) is for generating new lists
|
||||||
|
- [brace matching](#brace-matching) is for filtering existing lists
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><strong>More about brace expansion</strong> (click to expand)</summary>
|
||||||
|
|
||||||
|
There are two main types of brace expansion:
|
||||||
|
|
||||||
|
1. **lists**: which are defined using comma-separated values inside curly braces: `{a,b,c}`
|
||||||
|
2. **sequences**: which are defined using a starting value and an ending value, separated by two dots: `a{1..3}b`. Optionally, a third argument may be passed to define a "step" or increment to use: `a{1..100..10}b`. These are also sometimes referred to as "ranges".
|
||||||
|
|
||||||
|
Here are some example brace patterns to illustrate how they work:
|
||||||
|
|
||||||
|
**Sets**
|
||||||
|
|
||||||
|
```
|
||||||
|
{a,b,c} => a b c
|
||||||
|
{a,b,c}{1,2} => a1 a2 b1 b2 c1 c2
|
||||||
|
```
|
||||||
|
|
||||||
|
**Sequences**
|
||||||
|
|
||||||
|
```
|
||||||
|
{1..9} => 1 2 3 4 5 6 7 8 9
|
||||||
|
{4..-4} => 4 3 2 1 0 -1 -2 -3 -4
|
||||||
|
{1..20..3} => 1 4 7 10 13 16 19
|
||||||
|
{a..j} => a b c d e f g h i j
|
||||||
|
{j..a} => j i h g f e d c b a
|
||||||
|
{a..z..3} => a d g j m p s v y
|
||||||
|
```
|
||||||
|
|
||||||
|
**Combination**
|
||||||
|
|
||||||
|
Sets and sequences can be mixed together or used along with any other strings.
|
||||||
|
|
||||||
|
```
|
||||||
|
{a,b,c}{1..3} => a1 a2 a3 b1 b2 b3 c1 c2 c3
|
||||||
|
foo/{a,b,c}/bar => foo/a/bar foo/b/bar foo/c/bar
|
||||||
|
```
|
||||||
|
|
||||||
|
The fact that braces can be "expanded" from relatively simple patterns makes them ideal for quickly generating test fixtures, file paths, and similar use cases.
|
||||||
|
|
||||||
|
## Brace matching
|
||||||
|
|
||||||
|
In addition to _expansion_, brace patterns are also useful for performing regular-expression-like matching.
|
||||||
|
|
||||||
|
For example, the pattern `foo/{1..3}/bar` would match any of following strings:
|
||||||
|
|
||||||
|
```
|
||||||
|
foo/1/bar
|
||||||
|
foo/2/bar
|
||||||
|
foo/3/bar
|
||||||
|
```
|
||||||
|
|
||||||
|
But not:
|
||||||
|
|
||||||
|
```
|
||||||
|
baz/1/qux
|
||||||
|
baz/2/qux
|
||||||
|
baz/3/qux
|
||||||
|
```
|
||||||
|
|
||||||
|
Braces can also be combined with [glob patterns](https://github.com/jonschlinkert/micromatch) to perform more advanced wildcard matching. For example, the pattern `*/{1..3}/*` would match any of following strings:
|
||||||
|
|
||||||
|
```
|
||||||
|
foo/1/bar
|
||||||
|
foo/2/bar
|
||||||
|
foo/3/bar
|
||||||
|
baz/1/qux
|
||||||
|
baz/2/qux
|
||||||
|
baz/3/qux
|
||||||
|
```
|
||||||
|
|
||||||
|
## Brace matching pitfalls
|
||||||
|
|
||||||
|
Although brace patterns offer a user-friendly way of matching ranges or sets of strings, there are also some major disadvantages and potential risks you should be aware of.
|
||||||
|
|
||||||
|
### tldr
|
||||||
|
|
||||||
|
**"brace bombs"**
|
||||||
|
|
||||||
|
- brace expansion can eat up a huge amount of processing resources
|
||||||
|
- as brace patterns increase _linearly in size_, the system resources required to expand the pattern increase exponentially
|
||||||
|
- users can accidentally (or intentially) exhaust your system's resources resulting in the equivalent of a DoS attack (bonus: no programming knowledge is required!)
|
||||||
|
|
||||||
|
For a more detailed explanation with examples, see the [geometric complexity](#geometric-complexity) section.
|
||||||
|
|
||||||
|
### The solution
|
||||||
|
|
||||||
|
Jump to the [performance section](#performance) to see how Braces solves this problem in comparison to other libraries.
|
||||||
|
|
||||||
|
### Geometric complexity
|
||||||
|
|
||||||
|
At minimum, brace patterns with sets limited to two elements have quadradic or `O(n^2)` complexity. But the complexity of the algorithm increases exponentially as the number of sets, _and elements per set_, increases, which is `O(n^c)`.
|
||||||
|
|
||||||
|
For example, the following sets demonstrate quadratic (`O(n^2)`) complexity:
|
||||||
|
|
||||||
|
```
|
||||||
|
{1,2}{3,4} => (2X2) => 13 14 23 24
|
||||||
|
{1,2}{3,4}{5,6} => (2X2X2) => 135 136 145 146 235 236 245 246
|
||||||
|
```
|
||||||
|
|
||||||
|
But add an element to a set, and we get a n-fold Cartesian product with `O(n^c)` complexity:
|
||||||
|
|
||||||
|
```
|
||||||
|
{1,2,3}{4,5,6}{7,8,9} => (3X3X3) => 147 148 149 157 158 159 167 168 169 247 248
|
||||||
|
249 257 258 259 267 268 269 347 348 349 357
|
||||||
|
358 359 367 368 369
|
||||||
|
```
|
||||||
|
|
||||||
|
Now, imagine how this complexity grows given that each element is a n-tuple:
|
||||||
|
|
||||||
|
```
|
||||||
|
{1..100}{1..100} => (100X100) => 10,000 elements (38.4 kB)
|
||||||
|
{1..100}{1..100}{1..100} => (100X100X100) => 1,000,000 elements (5.76 MB)
|
||||||
|
```
|
||||||
|
|
||||||
|
Although these examples are clearly contrived, they demonstrate how brace patterns can quickly grow out of control.
|
||||||
|
|
||||||
|
**More information**
|
||||||
|
|
||||||
|
Interested in learning more about brace expansion?
|
||||||
|
|
||||||
|
- [linuxjournal/bash-brace-expansion](http://www.linuxjournal.com/content/bash-brace-expansion)
|
||||||
|
- [rosettacode/Brace_expansion](https://rosettacode.org/wiki/Brace_expansion)
|
||||||
|
- [cartesian product](https://en.wikipedia.org/wiki/Cartesian_product)
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
## Performance
|
||||||
|
|
||||||
|
Braces is not only screaming fast, it's also more accurate the other brace expansion libraries.
|
||||||
|
|
||||||
|
### Better algorithms
|
||||||
|
|
||||||
|
Fortunately there is a solution to the ["brace bomb" problem](#brace-matching-pitfalls): _don't expand brace patterns into an array when they're used for matching_.
|
||||||
|
|
||||||
|
Instead, convert the pattern into an optimized regular expression. This is easier said than done, and braces is the only library that does this currently.
|
||||||
|
|
||||||
|
**The proof is in the numbers**
|
||||||
|
|
||||||
|
Minimatch gets exponentially slower as patterns increase in complexity, braces does not. The following results were generated using `braces()` and `minimatch.braceExpand()`, respectively.
|
||||||
|
|
||||||
|
| **Pattern** | **braces** | **[minimatch][]** |
|
||||||
|
| --------------------------- | ------------------- | ---------------------------- |
|
||||||
|
| `{1..9007199254740991}`[^1] | `298 B` (5ms 459μs) | N/A (freezes) |
|
||||||
|
| `{1..1000000000000000}` | `41 B` (1ms 15μs) | N/A (freezes) |
|
||||||
|
| `{1..100000000000000}` | `40 B` (890μs) | N/A (freezes) |
|
||||||
|
| `{1..10000000000000}` | `39 B` (2ms 49μs) | N/A (freezes) |
|
||||||
|
| `{1..1000000000000}` | `38 B` (608μs) | N/A (freezes) |
|
||||||
|
| `{1..100000000000}` | `37 B` (397μs) | N/A (freezes) |
|
||||||
|
| `{1..10000000000}` | `35 B` (983μs) | N/A (freezes) |
|
||||||
|
| `{1..1000000000}` | `34 B` (798μs) | N/A (freezes) |
|
||||||
|
| `{1..100000000}` | `33 B` (733μs) | N/A (freezes) |
|
||||||
|
| `{1..10000000}` | `32 B` (5ms 632μs) | `78.89 MB` (16s 388ms 569μs) |
|
||||||
|
| `{1..1000000}` | `31 B` (1ms 381μs) | `6.89 MB` (1s 496ms 887μs) |
|
||||||
|
| `{1..100000}` | `30 B` (950μs) | `588.89 kB` (146ms 921μs) |
|
||||||
|
| `{1..10000}` | `29 B` (1ms 114μs) | `48.89 kB` (14ms 187μs) |
|
||||||
|
| `{1..1000}` | `28 B` (760μs) | `3.89 kB` (1ms 453μs) |
|
||||||
|
| `{1..100}` | `22 B` (345μs) | `291 B` (196μs) |
|
||||||
|
| `{1..10}` | `10 B` (533μs) | `20 B` (37μs) |
|
||||||
|
| `{1..3}` | `7 B` (190μs) | `5 B` (27μs) |
|
||||||
|
|
||||||
|
### Faster algorithms
|
||||||
|
|
||||||
|
When you need expansion, braces is still much faster.
|
||||||
|
|
||||||
|
_(the following results were generated using `braces.expand()` and `minimatch.braceExpand()`, respectively)_
|
||||||
|
|
||||||
|
| **Pattern** | **braces** | **[minimatch][]** |
|
||||||
|
| --------------- | --------------------------- | ---------------------------- |
|
||||||
|
| `{1..10000000}` | `78.89 MB` (2s 698ms 642μs) | `78.89 MB` (18s 601ms 974μs) |
|
||||||
|
| `{1..1000000}` | `6.89 MB` (458ms 576μs) | `6.89 MB` (1s 491ms 621μs) |
|
||||||
|
| `{1..100000}` | `588.89 kB` (20ms 728μs) | `588.89 kB` (156ms 919μs) |
|
||||||
|
| `{1..10000}` | `48.89 kB` (2ms 202μs) | `48.89 kB` (13ms 641μs) |
|
||||||
|
| `{1..1000}` | `3.89 kB` (1ms 796μs) | `3.89 kB` (1ms 958μs) |
|
||||||
|
| `{1..100}` | `291 B` (424μs) | `291 B` (211μs) |
|
||||||
|
| `{1..10}` | `20 B` (487μs) | `20 B` (72μs) |
|
||||||
|
| `{1..3}` | `5 B` (166μs) | `5 B` (27μs) |
|
||||||
|
|
||||||
|
If you'd like to run these comparisons yourself, see [test/support/generate.js](test/support/generate.js).
|
||||||
|
|
||||||
|
## Benchmarks
|
||||||
|
|
||||||
|
### Running benchmarks
|
||||||
|
|
||||||
|
Install dev dependencies:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm i -d && npm benchmark
|
||||||
|
```
|
||||||
|
|
||||||
|
### Latest results
|
||||||
|
|
||||||
|
Braces is more accurate, without sacrificing performance.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
● expand - range (expanded)
|
||||||
|
braces x 53,167 ops/sec ±0.12% (102 runs sampled)
|
||||||
|
minimatch x 11,378 ops/sec ±0.10% (102 runs sampled)
|
||||||
|
● expand - range (optimized for regex)
|
||||||
|
braces x 373,442 ops/sec ±0.04% (100 runs sampled)
|
||||||
|
minimatch x 3,262 ops/sec ±0.18% (100 runs sampled)
|
||||||
|
● expand - nested ranges (expanded)
|
||||||
|
braces x 33,921 ops/sec ±0.09% (99 runs sampled)
|
||||||
|
minimatch x 10,855 ops/sec ±0.28% (100 runs sampled)
|
||||||
|
● expand - nested ranges (optimized for regex)
|
||||||
|
braces x 287,479 ops/sec ±0.52% (98 runs sampled)
|
||||||
|
minimatch x 3,219 ops/sec ±0.28% (101 runs sampled)
|
||||||
|
● expand - set (expanded)
|
||||||
|
braces x 238,243 ops/sec ±0.19% (97 runs sampled)
|
||||||
|
minimatch x 538,268 ops/sec ±0.31% (96 runs sampled)
|
||||||
|
● expand - set (optimized for regex)
|
||||||
|
braces x 321,844 ops/sec ±0.10% (97 runs sampled)
|
||||||
|
minimatch x 140,600 ops/sec ±0.15% (100 runs sampled)
|
||||||
|
● expand - nested sets (expanded)
|
||||||
|
braces x 165,371 ops/sec ±0.42% (96 runs sampled)
|
||||||
|
minimatch x 337,720 ops/sec ±0.28% (100 runs sampled)
|
||||||
|
● expand - nested sets (optimized for regex)
|
||||||
|
braces x 242,948 ops/sec ±0.12% (99 runs sampled)
|
||||||
|
minimatch x 87,403 ops/sec ±0.79% (96 runs sampled)
|
||||||
|
```
|
||||||
|
|
||||||
|
## About
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><strong>Contributing</strong></summary>
|
||||||
|
|
||||||
|
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><strong>Running Tests</strong></summary>
|
||||||
|
|
||||||
|
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install && npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><strong>Building docs</strong></summary>
|
||||||
|
|
||||||
|
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||||
|
|
||||||
|
To generate the readme, run the following command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
### Contributors
|
||||||
|
|
||||||
|
| **Commits** | **Contributor** |
|
||||||
|
| ----------- | ------------------------------------------------------------- |
|
||||||
|
| 197 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||||
|
| 4 | [doowb](https://github.com/doowb) |
|
||||||
|
| 1 | [es128](https://github.com/es128) |
|
||||||
|
| 1 | [eush77](https://github.com/eush77) |
|
||||||
|
| 1 | [hemanth](https://github.com/hemanth) |
|
||||||
|
| 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |
|
||||||
|
|
||||||
|
### Author
|
||||||
|
|
||||||
|
**Jon Schlinkert**
|
||||||
|
|
||||||
|
- [GitHub Profile](https://github.com/jonschlinkert)
|
||||||
|
- [Twitter Profile](https://twitter.com/jonschlinkert)
|
||||||
|
- [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
|
||||||
|
|
||||||
|
### License
|
||||||
|
|
||||||
|
Copyright © 2019, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||||
|
Released under the [MIT License](LICENSE).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on April 08, 2019._
|
||||||
170
node_modules/braces/index.js
generated
vendored
Normal file
170
node_modules/braces/index.js
generated
vendored
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const stringify = require('./lib/stringify');
|
||||||
|
const compile = require('./lib/compile');
|
||||||
|
const expand = require('./lib/expand');
|
||||||
|
const parse = require('./lib/parse');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expand the given pattern or create a regex-compatible string.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const braces = require('braces');
|
||||||
|
* console.log(braces('{a,b,c}', { compile: true })); //=> ['(a|b|c)']
|
||||||
|
* console.log(braces('{a,b,c}')); //=> ['a', 'b', 'c']
|
||||||
|
* ```
|
||||||
|
* @param {String} `str`
|
||||||
|
* @param {Object} `options`
|
||||||
|
* @return {String}
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
const braces = (input, options = {}) => {
|
||||||
|
let output = [];
|
||||||
|
|
||||||
|
if (Array.isArray(input)) {
|
||||||
|
for (const pattern of input) {
|
||||||
|
const result = braces.create(pattern, options);
|
||||||
|
if (Array.isArray(result)) {
|
||||||
|
output.push(...result);
|
||||||
|
} else {
|
||||||
|
output.push(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
output = [].concat(braces.create(input, options));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options && options.expand === true && options.nodupes === true) {
|
||||||
|
output = [...new Set(output)];
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse the given `str` with the given `options`.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* // braces.parse(pattern, [, options]);
|
||||||
|
* const ast = braces.parse('a/{b,c}/d');
|
||||||
|
* console.log(ast);
|
||||||
|
* ```
|
||||||
|
* @param {String} pattern Brace pattern to parse
|
||||||
|
* @param {Object} options
|
||||||
|
* @return {Object} Returns an AST
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
braces.parse = (input, options = {}) => parse(input, options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a braces string from an AST, or an AST node.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const braces = require('braces');
|
||||||
|
* let ast = braces.parse('foo/{a,b}/bar');
|
||||||
|
* console.log(stringify(ast.nodes[2])); //=> '{a,b}'
|
||||||
|
* ```
|
||||||
|
* @param {String} `input` Brace pattern or AST.
|
||||||
|
* @param {Object} `options`
|
||||||
|
* @return {Array} Returns an array of expanded values.
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
braces.stringify = (input, options = {}) => {
|
||||||
|
if (typeof input === 'string') {
|
||||||
|
return stringify(braces.parse(input, options), options);
|
||||||
|
}
|
||||||
|
return stringify(input, options);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compiles a brace pattern into a regex-compatible, optimized string.
|
||||||
|
* This method is called by the main [braces](#braces) function by default.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const braces = require('braces');
|
||||||
|
* console.log(braces.compile('a/{b,c}/d'));
|
||||||
|
* //=> ['a/(b|c)/d']
|
||||||
|
* ```
|
||||||
|
* @param {String} `input` Brace pattern or AST.
|
||||||
|
* @param {Object} `options`
|
||||||
|
* @return {Array} Returns an array of expanded values.
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
braces.compile = (input, options = {}) => {
|
||||||
|
if (typeof input === 'string') {
|
||||||
|
input = braces.parse(input, options);
|
||||||
|
}
|
||||||
|
return compile(input, options);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expands a brace pattern into an array. This method is called by the
|
||||||
|
* main [braces](#braces) function when `options.expand` is true. Before
|
||||||
|
* using this method it's recommended that you read the [performance notes](#performance))
|
||||||
|
* and advantages of using [.compile](#compile) instead.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const braces = require('braces');
|
||||||
|
* console.log(braces.expand('a/{b,c}/d'));
|
||||||
|
* //=> ['a/b/d', 'a/c/d'];
|
||||||
|
* ```
|
||||||
|
* @param {String} `pattern` Brace pattern
|
||||||
|
* @param {Object} `options`
|
||||||
|
* @return {Array} Returns an array of expanded values.
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
braces.expand = (input, options = {}) => {
|
||||||
|
if (typeof input === 'string') {
|
||||||
|
input = braces.parse(input, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
let result = expand(input, options);
|
||||||
|
|
||||||
|
// filter out empty strings if specified
|
||||||
|
if (options.noempty === true) {
|
||||||
|
result = result.filter(Boolean);
|
||||||
|
}
|
||||||
|
|
||||||
|
// filter out duplicates if specified
|
||||||
|
if (options.nodupes === true) {
|
||||||
|
result = [...new Set(result)];
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes a brace pattern and returns either an expanded array
|
||||||
|
* (if `options.expand` is true), a highly optimized regex-compatible string.
|
||||||
|
* This method is called by the main [braces](#braces) function.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const braces = require('braces');
|
||||||
|
* console.log(braces.create('user-{200..300}/project-{a,b,c}-{1..10}'))
|
||||||
|
* //=> 'user-(20[0-9]|2[1-9][0-9]|300)/project-(a|b|c)-([1-9]|10)'
|
||||||
|
* ```
|
||||||
|
* @param {String} `pattern` Brace pattern
|
||||||
|
* @param {Object} `options`
|
||||||
|
* @return {Array} Returns an array of expanded values.
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
braces.create = (input, options = {}) => {
|
||||||
|
if (input === '' || input.length < 3) {
|
||||||
|
return [input];
|
||||||
|
}
|
||||||
|
|
||||||
|
return options.expand !== true
|
||||||
|
? braces.compile(input, options)
|
||||||
|
: braces.expand(input, options);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expose "braces"
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = braces;
|
||||||
60
node_modules/braces/lib/compile.js
generated
vendored
Normal file
60
node_modules/braces/lib/compile.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const fill = require('fill-range');
|
||||||
|
const utils = require('./utils');
|
||||||
|
|
||||||
|
const compile = (ast, options = {}) => {
|
||||||
|
const walk = (node, parent = {}) => {
|
||||||
|
const invalidBlock = utils.isInvalidBrace(parent);
|
||||||
|
const invalidNode = node.invalid === true && options.escapeInvalid === true;
|
||||||
|
const invalid = invalidBlock === true || invalidNode === true;
|
||||||
|
const prefix = options.escapeInvalid === true ? '\\' : '';
|
||||||
|
let output = '';
|
||||||
|
|
||||||
|
if (node.isOpen === true) {
|
||||||
|
return prefix + node.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.isClose === true) {
|
||||||
|
console.log('node.isClose', prefix, node.value);
|
||||||
|
return prefix + node.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.type === 'open') {
|
||||||
|
return invalid ? prefix + node.value : '(';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.type === 'close') {
|
||||||
|
return invalid ? prefix + node.value : ')';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.type === 'comma') {
|
||||||
|
return node.prev.type === 'comma' ? '' : invalid ? node.value : '|';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.value) {
|
||||||
|
return node.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.nodes && node.ranges > 0) {
|
||||||
|
const args = utils.reduce(node.nodes);
|
||||||
|
const range = fill(...args, { ...options, wrap: false, toRegex: true, strictZeros: true });
|
||||||
|
|
||||||
|
if (range.length !== 0) {
|
||||||
|
return args.length > 1 && range.length > 1 ? `(${range})` : range;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.nodes) {
|
||||||
|
for (const child of node.nodes) {
|
||||||
|
output += walk(child, node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
return walk(ast);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = compile;
|
||||||
57
node_modules/braces/lib/constants.js
generated
vendored
Normal file
57
node_modules/braces/lib/constants.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
MAX_LENGTH: 10000,
|
||||||
|
|
||||||
|
// Digits
|
||||||
|
CHAR_0: '0', /* 0 */
|
||||||
|
CHAR_9: '9', /* 9 */
|
||||||
|
|
||||||
|
// Alphabet chars.
|
||||||
|
CHAR_UPPERCASE_A: 'A', /* A */
|
||||||
|
CHAR_LOWERCASE_A: 'a', /* a */
|
||||||
|
CHAR_UPPERCASE_Z: 'Z', /* Z */
|
||||||
|
CHAR_LOWERCASE_Z: 'z', /* z */
|
||||||
|
|
||||||
|
CHAR_LEFT_PARENTHESES: '(', /* ( */
|
||||||
|
CHAR_RIGHT_PARENTHESES: ')', /* ) */
|
||||||
|
|
||||||
|
CHAR_ASTERISK: '*', /* * */
|
||||||
|
|
||||||
|
// Non-alphabetic chars.
|
||||||
|
CHAR_AMPERSAND: '&', /* & */
|
||||||
|
CHAR_AT: '@', /* @ */
|
||||||
|
CHAR_BACKSLASH: '\\', /* \ */
|
||||||
|
CHAR_BACKTICK: '`', /* ` */
|
||||||
|
CHAR_CARRIAGE_RETURN: '\r', /* \r */
|
||||||
|
CHAR_CIRCUMFLEX_ACCENT: '^', /* ^ */
|
||||||
|
CHAR_COLON: ':', /* : */
|
||||||
|
CHAR_COMMA: ',', /* , */
|
||||||
|
CHAR_DOLLAR: '$', /* . */
|
||||||
|
CHAR_DOT: '.', /* . */
|
||||||
|
CHAR_DOUBLE_QUOTE: '"', /* " */
|
||||||
|
CHAR_EQUAL: '=', /* = */
|
||||||
|
CHAR_EXCLAMATION_MARK: '!', /* ! */
|
||||||
|
CHAR_FORM_FEED: '\f', /* \f */
|
||||||
|
CHAR_FORWARD_SLASH: '/', /* / */
|
||||||
|
CHAR_HASH: '#', /* # */
|
||||||
|
CHAR_HYPHEN_MINUS: '-', /* - */
|
||||||
|
CHAR_LEFT_ANGLE_BRACKET: '<', /* < */
|
||||||
|
CHAR_LEFT_CURLY_BRACE: '{', /* { */
|
||||||
|
CHAR_LEFT_SQUARE_BRACKET: '[', /* [ */
|
||||||
|
CHAR_LINE_FEED: '\n', /* \n */
|
||||||
|
CHAR_NO_BREAK_SPACE: '\u00A0', /* \u00A0 */
|
||||||
|
CHAR_PERCENT: '%', /* % */
|
||||||
|
CHAR_PLUS: '+', /* + */
|
||||||
|
CHAR_QUESTION_MARK: '?', /* ? */
|
||||||
|
CHAR_RIGHT_ANGLE_BRACKET: '>', /* > */
|
||||||
|
CHAR_RIGHT_CURLY_BRACE: '}', /* } */
|
||||||
|
CHAR_RIGHT_SQUARE_BRACKET: ']', /* ] */
|
||||||
|
CHAR_SEMICOLON: ';', /* ; */
|
||||||
|
CHAR_SINGLE_QUOTE: '\'', /* ' */
|
||||||
|
CHAR_SPACE: ' ', /* */
|
||||||
|
CHAR_TAB: '\t', /* \t */
|
||||||
|
CHAR_UNDERSCORE: '_', /* _ */
|
||||||
|
CHAR_VERTICAL_LINE: '|', /* | */
|
||||||
|
CHAR_ZERO_WIDTH_NOBREAK_SPACE: '\uFEFF' /* \uFEFF */
|
||||||
|
};
|
||||||
113
node_modules/braces/lib/expand.js
generated
vendored
Normal file
113
node_modules/braces/lib/expand.js
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const fill = require('fill-range');
|
||||||
|
const stringify = require('./stringify');
|
||||||
|
const utils = require('./utils');
|
||||||
|
|
||||||
|
const append = (queue = '', stash = '', enclose = false) => {
|
||||||
|
const result = [];
|
||||||
|
|
||||||
|
queue = [].concat(queue);
|
||||||
|
stash = [].concat(stash);
|
||||||
|
|
||||||
|
if (!stash.length) return queue;
|
||||||
|
if (!queue.length) {
|
||||||
|
return enclose ? utils.flatten(stash).map(ele => `{${ele}}`) : stash;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const item of queue) {
|
||||||
|
if (Array.isArray(item)) {
|
||||||
|
for (const value of item) {
|
||||||
|
result.push(append(value, stash, enclose));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (let ele of stash) {
|
||||||
|
if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
|
||||||
|
result.push(Array.isArray(ele) ? append(item, ele, enclose) : item + ele);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return utils.flatten(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
const expand = (ast, options = {}) => {
|
||||||
|
const rangeLimit = options.rangeLimit === undefined ? 1000 : options.rangeLimit;
|
||||||
|
|
||||||
|
const walk = (node, parent = {}) => {
|
||||||
|
node.queue = [];
|
||||||
|
|
||||||
|
let p = parent;
|
||||||
|
let q = parent.queue;
|
||||||
|
|
||||||
|
while (p.type !== 'brace' && p.type !== 'root' && p.parent) {
|
||||||
|
p = p.parent;
|
||||||
|
q = p.queue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.invalid || node.dollar) {
|
||||||
|
q.push(append(q.pop(), stringify(node, options)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.type === 'brace' && node.invalid !== true && node.nodes.length === 2) {
|
||||||
|
q.push(append(q.pop(), ['{}']));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.nodes && node.ranges > 0) {
|
||||||
|
const args = utils.reduce(node.nodes);
|
||||||
|
|
||||||
|
if (utils.exceedsLimit(...args, options.step, rangeLimit)) {
|
||||||
|
throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
|
||||||
|
}
|
||||||
|
|
||||||
|
let range = fill(...args, options);
|
||||||
|
if (range.length === 0) {
|
||||||
|
range = stringify(node, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
q.push(append(q.pop(), range));
|
||||||
|
node.nodes = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const enclose = utils.encloseBrace(node);
|
||||||
|
let queue = node.queue;
|
||||||
|
let block = node;
|
||||||
|
|
||||||
|
while (block.type !== 'brace' && block.type !== 'root' && block.parent) {
|
||||||
|
block = block.parent;
|
||||||
|
queue = block.queue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < node.nodes.length; i++) {
|
||||||
|
const child = node.nodes[i];
|
||||||
|
|
||||||
|
if (child.type === 'comma' && node.type === 'brace') {
|
||||||
|
if (i === 1) queue.push('');
|
||||||
|
queue.push('');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (child.type === 'close') {
|
||||||
|
q.push(append(q.pop(), queue, enclose));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (child.value && child.type !== 'open') {
|
||||||
|
queue.push(append(queue.pop(), child.value));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (child.nodes) {
|
||||||
|
walk(child, node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return queue;
|
||||||
|
};
|
||||||
|
|
||||||
|
return utils.flatten(walk(ast));
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = expand;
|
||||||
331
node_modules/braces/lib/parse.js
generated
vendored
Normal file
331
node_modules/braces/lib/parse.js
generated
vendored
Normal file
@@ -0,0 +1,331 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const stringify = require('./stringify');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constants
|
||||||
|
*/
|
||||||
|
|
||||||
|
const {
|
||||||
|
MAX_LENGTH,
|
||||||
|
CHAR_BACKSLASH, /* \ */
|
||||||
|
CHAR_BACKTICK, /* ` */
|
||||||
|
CHAR_COMMA, /* , */
|
||||||
|
CHAR_DOT, /* . */
|
||||||
|
CHAR_LEFT_PARENTHESES, /* ( */
|
||||||
|
CHAR_RIGHT_PARENTHESES, /* ) */
|
||||||
|
CHAR_LEFT_CURLY_BRACE, /* { */
|
||||||
|
CHAR_RIGHT_CURLY_BRACE, /* } */
|
||||||
|
CHAR_LEFT_SQUARE_BRACKET, /* [ */
|
||||||
|
CHAR_RIGHT_SQUARE_BRACKET, /* ] */
|
||||||
|
CHAR_DOUBLE_QUOTE, /* " */
|
||||||
|
CHAR_SINGLE_QUOTE, /* ' */
|
||||||
|
CHAR_NO_BREAK_SPACE,
|
||||||
|
CHAR_ZERO_WIDTH_NOBREAK_SPACE
|
||||||
|
} = require('./constants');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* parse
|
||||||
|
*/
|
||||||
|
|
||||||
|
const parse = (input, options = {}) => {
|
||||||
|
if (typeof input !== 'string') {
|
||||||
|
throw new TypeError('Expected a string');
|
||||||
|
}
|
||||||
|
|
||||||
|
const opts = options || {};
|
||||||
|
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
||||||
|
if (input.length > max) {
|
||||||
|
throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const ast = { type: 'root', input, nodes: [] };
|
||||||
|
const stack = [ast];
|
||||||
|
let block = ast;
|
||||||
|
let prev = ast;
|
||||||
|
let brackets = 0;
|
||||||
|
const length = input.length;
|
||||||
|
let index = 0;
|
||||||
|
let depth = 0;
|
||||||
|
let value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helpers
|
||||||
|
*/
|
||||||
|
|
||||||
|
const advance = () => input[index++];
|
||||||
|
const push = node => {
|
||||||
|
if (node.type === 'text' && prev.type === 'dot') {
|
||||||
|
prev.type = 'text';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prev && prev.type === 'text' && node.type === 'text') {
|
||||||
|
prev.value += node.value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
block.nodes.push(node);
|
||||||
|
node.parent = block;
|
||||||
|
node.prev = prev;
|
||||||
|
prev = node;
|
||||||
|
return node;
|
||||||
|
};
|
||||||
|
|
||||||
|
push({ type: 'bos' });
|
||||||
|
|
||||||
|
while (index < length) {
|
||||||
|
block = stack[stack.length - 1];
|
||||||
|
value = advance();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalid chars
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (value === CHAR_ZERO_WIDTH_NOBREAK_SPACE || value === CHAR_NO_BREAK_SPACE) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escaped chars
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (value === CHAR_BACKSLASH) {
|
||||||
|
push({ type: 'text', value: (options.keepEscaping ? value : '') + advance() });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Right square bracket (literal): ']'
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (value === CHAR_RIGHT_SQUARE_BRACKET) {
|
||||||
|
push({ type: 'text', value: '\\' + value });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Left square bracket: '['
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (value === CHAR_LEFT_SQUARE_BRACKET) {
|
||||||
|
brackets++;
|
||||||
|
|
||||||
|
let next;
|
||||||
|
|
||||||
|
while (index < length && (next = advance())) {
|
||||||
|
value += next;
|
||||||
|
|
||||||
|
if (next === CHAR_LEFT_SQUARE_BRACKET) {
|
||||||
|
brackets++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (next === CHAR_BACKSLASH) {
|
||||||
|
value += advance();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
||||||
|
brackets--;
|
||||||
|
|
||||||
|
if (brackets === 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
push({ type: 'text', value });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parentheses
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (value === CHAR_LEFT_PARENTHESES) {
|
||||||
|
block = push({ type: 'paren', nodes: [] });
|
||||||
|
stack.push(block);
|
||||||
|
push({ type: 'text', value });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value === CHAR_RIGHT_PARENTHESES) {
|
||||||
|
if (block.type !== 'paren') {
|
||||||
|
push({ type: 'text', value });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
block = stack.pop();
|
||||||
|
push({ type: 'text', value });
|
||||||
|
block = stack[stack.length - 1];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Quotes: '|"|`
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
|
||||||
|
const open = value;
|
||||||
|
let next;
|
||||||
|
|
||||||
|
if (options.keepQuotes !== true) {
|
||||||
|
value = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
while (index < length && (next = advance())) {
|
||||||
|
if (next === CHAR_BACKSLASH) {
|
||||||
|
value += next + advance();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (next === open) {
|
||||||
|
if (options.keepQuotes === true) value += next;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
value += next;
|
||||||
|
}
|
||||||
|
|
||||||
|
push({ type: 'text', value });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Left curly brace: '{'
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (value === CHAR_LEFT_CURLY_BRACE) {
|
||||||
|
depth++;
|
||||||
|
|
||||||
|
const dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
|
||||||
|
const brace = {
|
||||||
|
type: 'brace',
|
||||||
|
open: true,
|
||||||
|
close: false,
|
||||||
|
dollar,
|
||||||
|
depth,
|
||||||
|
commas: 0,
|
||||||
|
ranges: 0,
|
||||||
|
nodes: []
|
||||||
|
};
|
||||||
|
|
||||||
|
block = push(brace);
|
||||||
|
stack.push(block);
|
||||||
|
push({ type: 'open', value });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Right curly brace: '}'
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (value === CHAR_RIGHT_CURLY_BRACE) {
|
||||||
|
if (block.type !== 'brace') {
|
||||||
|
push({ type: 'text', value });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const type = 'close';
|
||||||
|
block = stack.pop();
|
||||||
|
block.close = true;
|
||||||
|
|
||||||
|
push({ type, value });
|
||||||
|
depth--;
|
||||||
|
|
||||||
|
block = stack[stack.length - 1];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comma: ','
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (value === CHAR_COMMA && depth > 0) {
|
||||||
|
if (block.ranges > 0) {
|
||||||
|
block.ranges = 0;
|
||||||
|
const open = block.nodes.shift();
|
||||||
|
block.nodes = [open, { type: 'text', value: stringify(block) }];
|
||||||
|
}
|
||||||
|
|
||||||
|
push({ type: 'comma', value });
|
||||||
|
block.commas++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dot: '.'
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (value === CHAR_DOT && depth > 0 && block.commas === 0) {
|
||||||
|
const siblings = block.nodes;
|
||||||
|
|
||||||
|
if (depth === 0 || siblings.length === 0) {
|
||||||
|
push({ type: 'text', value });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prev.type === 'dot') {
|
||||||
|
block.range = [];
|
||||||
|
prev.value += value;
|
||||||
|
prev.type = 'range';
|
||||||
|
|
||||||
|
if (block.nodes.length !== 3 && block.nodes.length !== 5) {
|
||||||
|
block.invalid = true;
|
||||||
|
block.ranges = 0;
|
||||||
|
prev.type = 'text';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
block.ranges++;
|
||||||
|
block.args = [];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prev.type === 'range') {
|
||||||
|
siblings.pop();
|
||||||
|
|
||||||
|
const before = siblings[siblings.length - 1];
|
||||||
|
before.value += prev.value + value;
|
||||||
|
prev = before;
|
||||||
|
block.ranges--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
push({ type: 'dot', value });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Text
|
||||||
|
*/
|
||||||
|
|
||||||
|
push({ type: 'text', value });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark imbalanced braces and brackets as invalid
|
||||||
|
do {
|
||||||
|
block = stack.pop();
|
||||||
|
|
||||||
|
if (block.type !== 'root') {
|
||||||
|
block.nodes.forEach(node => {
|
||||||
|
if (!node.nodes) {
|
||||||
|
if (node.type === 'open') node.isOpen = true;
|
||||||
|
if (node.type === 'close') node.isClose = true;
|
||||||
|
if (!node.nodes) node.type = 'text';
|
||||||
|
node.invalid = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// get the location of the block on parent.nodes (block's siblings)
|
||||||
|
const parent = stack[stack.length - 1];
|
||||||
|
const index = parent.nodes.indexOf(block);
|
||||||
|
// replace the (invalid) block with it's nodes
|
||||||
|
parent.nodes.splice(index, 1, ...block.nodes);
|
||||||
|
}
|
||||||
|
} while (stack.length > 0);
|
||||||
|
|
||||||
|
push({ type: 'eos' });
|
||||||
|
return ast;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = parse;
|
||||||
32
node_modules/braces/lib/stringify.js
generated
vendored
Normal file
32
node_modules/braces/lib/stringify.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const utils = require('./utils');
|
||||||
|
|
||||||
|
module.exports = (ast, options = {}) => {
|
||||||
|
const stringify = (node, parent = {}) => {
|
||||||
|
const invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
|
||||||
|
const invalidNode = node.invalid === true && options.escapeInvalid === true;
|
||||||
|
let output = '';
|
||||||
|
|
||||||
|
if (node.value) {
|
||||||
|
if ((invalidBlock || invalidNode) && utils.isOpenOrClose(node)) {
|
||||||
|
return '\\' + node.value;
|
||||||
|
}
|
||||||
|
return node.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.value) {
|
||||||
|
return node.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.nodes) {
|
||||||
|
for (const child of node.nodes) {
|
||||||
|
output += stringify(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
|
||||||
|
return stringify(ast);
|
||||||
|
};
|
||||||
|
|
||||||
122
node_modules/braces/lib/utils.js
generated
vendored
Normal file
122
node_modules/braces/lib/utils.js
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
exports.isInteger = num => {
|
||||||
|
if (typeof num === 'number') {
|
||||||
|
return Number.isInteger(num);
|
||||||
|
}
|
||||||
|
if (typeof num === 'string' && num.trim() !== '') {
|
||||||
|
return Number.isInteger(Number(num));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find a node of the given type
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.find = (node, type) => node.nodes.find(node => node.type === type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find a node of the given type
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.exceedsLimit = (min, max, step = 1, limit) => {
|
||||||
|
if (limit === false) return false;
|
||||||
|
if (!exports.isInteger(min) || !exports.isInteger(max)) return false;
|
||||||
|
return ((Number(max) - Number(min)) / Number(step)) >= limit;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escape the given node with '\\' before node.value
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.escapeNode = (block, n = 0, type) => {
|
||||||
|
const node = block.nodes[n];
|
||||||
|
if (!node) return;
|
||||||
|
|
||||||
|
if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
|
||||||
|
if (node.escaped !== true) {
|
||||||
|
node.value = '\\' + node.value;
|
||||||
|
node.escaped = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the given brace node should be enclosed in literal braces
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.encloseBrace = node => {
|
||||||
|
if (node.type !== 'brace') return false;
|
||||||
|
if ((node.commas >> 0 + node.ranges >> 0) === 0) {
|
||||||
|
node.invalid = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if a brace node is invalid.
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.isInvalidBrace = block => {
|
||||||
|
if (block.type !== 'brace') return false;
|
||||||
|
if (block.invalid === true || block.dollar) return true;
|
||||||
|
if ((block.commas >> 0 + block.ranges >> 0) === 0) {
|
||||||
|
block.invalid = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (block.open !== true || block.close !== true) {
|
||||||
|
block.invalid = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if a node is an open or close node
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.isOpenOrClose = node => {
|
||||||
|
if (node.type === 'open' || node.type === 'close') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return node.open === true || node.close === true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reduce an array of text nodes.
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.reduce = nodes => nodes.reduce((acc, node) => {
|
||||||
|
if (node.type === 'text') acc.push(node.value);
|
||||||
|
if (node.type === 'range') node.type = 'text';
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flatten an array
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.flatten = (...args) => {
|
||||||
|
const result = [];
|
||||||
|
|
||||||
|
const flat = arr => {
|
||||||
|
for (let i = 0; i < arr.length; i++) {
|
||||||
|
const ele = arr[i];
|
||||||
|
|
||||||
|
if (Array.isArray(ele)) {
|
||||||
|
flat(ele);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ele !== undefined) {
|
||||||
|
result.push(ele);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
flat(args);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
77
node_modules/braces/package.json
generated
vendored
Normal file
77
node_modules/braces/package.json
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
{
|
||||||
|
"name": "braces",
|
||||||
|
"description": "Bash-like brace expansion, implemented in JavaScript. Safer than other brace expansion libs, with complete support for the Bash 4.3 braces specification, without sacrificing speed.",
|
||||||
|
"version": "3.0.3",
|
||||||
|
"homepage": "https://github.com/micromatch/braces",
|
||||||
|
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||||
|
"contributors": [
|
||||||
|
"Brian Woodward (https://twitter.com/doowb)",
|
||||||
|
"Elan Shanker (https://github.com/es128)",
|
||||||
|
"Eugene Sharygin (https://github.com/eush77)",
|
||||||
|
"hemanth.hm (http://h3manth.com)",
|
||||||
|
"Jon Schlinkert (http://twitter.com/jonschlinkert)"
|
||||||
|
],
|
||||||
|
"repository": "micromatch/braces",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/micromatch/braces/issues"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"files": [
|
||||||
|
"index.js",
|
||||||
|
"lib"
|
||||||
|
],
|
||||||
|
"main": "index.js",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "mocha",
|
||||||
|
"benchmark": "node benchmark"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"fill-range": "^7.1.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"ansi-colors": "^3.2.4",
|
||||||
|
"bash-path": "^2.0.1",
|
||||||
|
"gulp-format-md": "^2.0.0",
|
||||||
|
"mocha": "^6.1.1"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"alpha",
|
||||||
|
"alphabetical",
|
||||||
|
"bash",
|
||||||
|
"brace",
|
||||||
|
"braces",
|
||||||
|
"expand",
|
||||||
|
"expansion",
|
||||||
|
"filepath",
|
||||||
|
"fill",
|
||||||
|
"fs",
|
||||||
|
"glob",
|
||||||
|
"globbing",
|
||||||
|
"letter",
|
||||||
|
"match",
|
||||||
|
"matches",
|
||||||
|
"matching",
|
||||||
|
"number",
|
||||||
|
"numerical",
|
||||||
|
"path",
|
||||||
|
"range",
|
||||||
|
"ranges",
|
||||||
|
"sh"
|
||||||
|
],
|
||||||
|
"verb": {
|
||||||
|
"toc": false,
|
||||||
|
"layout": "default",
|
||||||
|
"tasks": [
|
||||||
|
"readme"
|
||||||
|
],
|
||||||
|
"lint": {
|
||||||
|
"reflinks": true
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"gulp-format-md"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
2
node_modules/buffer-equal-constant-time/.npmignore
generated
vendored
Normal file
2
node_modules/buffer-equal-constant-time/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
.*.sw[mnop]
|
||||||
|
node_modules/
|
||||||
4
node_modules/buffer-equal-constant-time/.travis.yml
generated
vendored
Normal file
4
node_modules/buffer-equal-constant-time/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
language: node_js
|
||||||
|
node_js:
|
||||||
|
- "0.11"
|
||||||
|
- "0.10"
|
||||||
12
node_modules/buffer-equal-constant-time/LICENSE.txt
generated
vendored
Normal file
12
node_modules/buffer-equal-constant-time/LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
Copyright (c) 2013, GoInstant Inc., a salesforce.com company
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of salesforce.com, nor GoInstant, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
50
node_modules/buffer-equal-constant-time/README.md
generated
vendored
Normal file
50
node_modules/buffer-equal-constant-time/README.md
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# buffer-equal-constant-time
|
||||||
|
|
||||||
|
Constant-time `Buffer` comparison for node.js. Should work with browserify too.
|
||||||
|
|
||||||
|
[](https://travis-ci.org/goinstant/buffer-equal-constant-time)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install buffer-equal-constant-time
|
||||||
|
```
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
var bufferEq = require('buffer-equal-constant-time');
|
||||||
|
|
||||||
|
var a = new Buffer('asdf');
|
||||||
|
var b = new Buffer('asdf');
|
||||||
|
if (bufferEq(a,b)) {
|
||||||
|
// the same!
|
||||||
|
} else {
|
||||||
|
// different in at least one byte!
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
If you'd like to install an `.equal()` method onto the node.js `Buffer` and
|
||||||
|
`SlowBuffer` prototypes:
|
||||||
|
|
||||||
|
```js
|
||||||
|
require('buffer-equal-constant-time').install();
|
||||||
|
|
||||||
|
var a = new Buffer('asdf');
|
||||||
|
var b = new Buffer('asdf');
|
||||||
|
if (a.equal(b)) {
|
||||||
|
// the same!
|
||||||
|
} else {
|
||||||
|
// different in at least one byte!
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
To get rid of the installed `.equal()` method, call `.restore()`:
|
||||||
|
|
||||||
|
```js
|
||||||
|
require('buffer-equal-constant-time').restore();
|
||||||
|
```
|
||||||
|
|
||||||
|
# Legal
|
||||||
|
|
||||||
|
© 2013 GoInstant Inc., a salesforce.com company
|
||||||
|
|
||||||
|
Licensed under the BSD 3-clause license.
|
||||||
41
node_modules/buffer-equal-constant-time/index.js
generated
vendored
Normal file
41
node_modules/buffer-equal-constant-time/index.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/*jshint node:true */
|
||||||
|
'use strict';
|
||||||
|
var Buffer = require('buffer').Buffer; // browserify
|
||||||
|
var SlowBuffer = require('buffer').SlowBuffer;
|
||||||
|
|
||||||
|
module.exports = bufferEq;
|
||||||
|
|
||||||
|
function bufferEq(a, b) {
|
||||||
|
|
||||||
|
// shortcutting on type is necessary for correctness
|
||||||
|
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// buffer sizes should be well-known information, so despite this
|
||||||
|
// shortcutting, it doesn't leak any information about the *contents* of the
|
||||||
|
// buffers.
|
||||||
|
if (a.length !== b.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var c = 0;
|
||||||
|
for (var i = 0; i < a.length; i++) {
|
||||||
|
/*jshint bitwise:false */
|
||||||
|
c |= a[i] ^ b[i]; // XOR
|
||||||
|
}
|
||||||
|
return c === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bufferEq.install = function() {
|
||||||
|
Buffer.prototype.equal = SlowBuffer.prototype.equal = function equal(that) {
|
||||||
|
return bufferEq(this, that);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
var origBufEqual = Buffer.prototype.equal;
|
||||||
|
var origSlowBufEqual = SlowBuffer.prototype.equal;
|
||||||
|
bufferEq.restore = function() {
|
||||||
|
Buffer.prototype.equal = origBufEqual;
|
||||||
|
SlowBuffer.prototype.equal = origSlowBufEqual;
|
||||||
|
};
|
||||||
21
node_modules/buffer-equal-constant-time/package.json
generated
vendored
Normal file
21
node_modules/buffer-equal-constant-time/package.json
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "buffer-equal-constant-time",
|
||||||
|
"version": "1.0.1",
|
||||||
|
"description": "Constant-time comparison of Buffers",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "mocha test.js"
|
||||||
|
},
|
||||||
|
"repository": "git@github.com:goinstant/buffer-equal-constant-time.git",
|
||||||
|
"keywords": [
|
||||||
|
"buffer",
|
||||||
|
"equal",
|
||||||
|
"constant-time",
|
||||||
|
"crypto"
|
||||||
|
],
|
||||||
|
"author": "GoInstant Inc., a salesforce.com company",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"devDependencies": {
|
||||||
|
"mocha": "~1.15.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
42
node_modules/buffer-equal-constant-time/test.js
generated
vendored
Normal file
42
node_modules/buffer-equal-constant-time/test.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
/*jshint node:true */
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var bufferEq = require('./index');
|
||||||
|
var assert = require('assert');
|
||||||
|
|
||||||
|
describe('buffer-equal-constant-time', function() {
|
||||||
|
var a = new Buffer('asdfasdf123456');
|
||||||
|
var b = new Buffer('asdfasdf123456');
|
||||||
|
var c = new Buffer('asdfasdf');
|
||||||
|
|
||||||
|
describe('bufferEq', function() {
|
||||||
|
it('says a == b', function() {
|
||||||
|
assert.strictEqual(bufferEq(a, b), true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('says a != c', function() {
|
||||||
|
assert.strictEqual(bufferEq(a, c), false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('install/restore', function() {
|
||||||
|
before(function() {
|
||||||
|
bufferEq.install();
|
||||||
|
});
|
||||||
|
after(function() {
|
||||||
|
bufferEq.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('installed an .equal method', function() {
|
||||||
|
var SlowBuffer = require('buffer').SlowBuffer;
|
||||||
|
assert.ok(Buffer.prototype.equal);
|
||||||
|
assert.ok(SlowBuffer.prototype.equal);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('infected existing Buffers', function() {
|
||||||
|
assert.strictEqual(a.equal(b), true);
|
||||||
|
assert.strictEqual(a.equal(c), false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user