
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
@easylibs/tempdata
Advanced tools
`TempData` is a JavaScript utility class that allows you to store data temporarily in the browser using indexed databases. This approach is very convenient, for example, if you want to create temporary data to submit to the server later, or if you plan to
TempData is a JavaScript utility class that allows you to store data temporarily in the browser using indexed databases. This approach is very convenient, for example, if you want to create temporary data to submit to the server later, or if you plan to send multiple data to the server at once. In this case, you can save new data one by one and then submit them together. This way, the data can be retained even after closing your application.
To use the TempData class, you can install it from npm:
npm install @easylibs/tempdata
# Or
yarn add @easylibs/tempdata
# Or
pnpm add @easylibs/tempdata
Or use direct inclusion with CDN:
<!--MINIFIED-->
<script src="https://cdn.jsdelivr.net/npm/@easylibs/tempdata@latest/dist/tempdata.min.js"></script>
<script src="https://unpkg.com/@easylibs/tempdata@latest/dist/tempdata.min.js"></script>
<!-- OR UNMINIFIED-->
<script src="https://cdn.jsdelivr.net/npm/@easylibs/tempdata@latest/dist/tempdata.js"></script>
<script src="https://unpkg.com/@easylibs/tempdata@latest/dist/tempdata.js"></script>
To use the TempData class, you first need to create an instance of the class. You can do this by providing the name of the database, the name of the object store, and the version of the database.
const database = new TempData('my_database',[
{ osname:"products",options:{autoIncrement:true} },
{ osname:"customers", options:{autoIncrement:true} }
]);
This code creates a new TempData database called my-database with object stores called products, customers respectively. It then adds the data objects to the object stores. The add method returns a promise that resolves to an object indicating the success of the operation.
const products = [
{
"name": "Natural wood chair from Gabon",
"price": 150600,
"color":"undefined",
"description": "Made by N'KOK",
"category":"fournitures",
"seller": "Evangzat"
},
{
"name": "Samsung C3050",
"price": 3200,
"color":"black",
"description": "People from 2005 don't kwnow It",
"category":"Smart phone",
"seller": "Elise Service"
},
{
"name": "MSI All Of One Desktop",
"price": 475000,
"color":"undefined",
"description": "Very expensive for you",
"category":"Desktop",
"seller": "Elise Service"
}
];
const customers = [
{
"firstname":"Guy Bertrant",
"lastname":"Mabiala Mabiala",
"email": "guybertrant@gmail.com",
"phone": "+24174421200",
"sex":"male",
"nationality":"Gabonese"
},
{
"firstname":"Fatima",
"lastname":"Diom",
"email": "fatima2@gmail.com",
"phone": "+221771234567",
"sex":"female",
"nationality":"Senegalese"
},
{
"firstname":"Cynthia Lesly",
"lastname":"Fiangwa",
"email": "cynthiafiangwa@gmail.com",
"phone": "+237664584741",
"sex":"female",
"nationality":"Cameroon"
},
{
"firstname": "Marina",
"lastname": "Moulouma Moussavou",
"phone": "+241066001736",
"email": "marina.ms@gmail.com",
"sex": "female",
"nationality":"Gabonese"
}
]
tempdata.add(customers,"customers");
tempdata.add(products,"products");
The add method returns a promise that resolves to an object indicating the success of the operation. The object has the following properties:
success: A boolean value indicating whether the operation was successful.elementObject: The object that was added to the database.This code creates a new TempData database called my-database with an object store called customers and products. It then adds the data object to the object store. The add method returns a promise that resolves to an object indicating the success of the operation.
If you do not specify the object store in the add method, TempData will consider that it is the one specified by default when creating the instance, assuming that you had defined it. Otherwise an error will be thrown.
database.read().then((data)=>{
console.log(data) // retrieve all products
})
database.readOne(6).then((data)=>{
console.log(data)
}) // retrieve customer to index 6
database.readBy({sex:"female",nationality:"Senegalese"}).then((data)=>{
console.log(data)
})
database.readOneBy({color:"undefined"}).then((data)=>{
console.log(data)
})
To delete data from the database, you can use the deleteAll, deleteOneor deleteOS methods
tempdata.deleteDB() // delete database
database.deleteOne(1,"customers") // delete one element at index 1 from "customers'
tempdata.deleteOS('products') // delete object store "products'
The refactorIndexes method can be used to refactor the indexes of the indexed data.
The TempData class provides the following methods:
add(data): Adds one or more items to IDBObjectStore with the provided object. The data can be an object or an array of objects.readOne(i,type): Retrieve the element at the specified index.readOneBy(criteria,type): Retrieve the element at the specified index according to the criteria.read(): Recovers all elements.readBy(criteria): Recovers all elements that respect the critaria.update(id,data): Updates an item.deleteOne(id,refactoringShortKeyString,callback): Deletes the object with the specified ID from the IDBObjectStore.deleteOS: Delete the ObjectStoredeleteAll(): Removes every record stored in the database.isItEmpty(): Checks if databse is empty.length(): Retrieves the length of the object store.isItExpired(): Check expriation date of databasegetObjectStore(access): Retrieves the IDBObjectStore with the specified access mode from the opened database.refactorIndexes(refactoringShortKeyString): Refactors the indexes of the indexed data based on the provided string.FAQs
`TempData` is a JavaScript utility class that allows you to store data temporarily in the browser using indexed databases. This approach is very convenient, for example, if you want to create temporary data to submit to the server later, or if you plan to
We found that @easylibs/tempdata demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.