New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

can-define-backup

Package Overview
Dependencies
Maintainers
5
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-define-backup

Backup and restore a DefineMap state

  • 1.0.0
  • npm
  • Socket score

Version published
Weekly downloads
176
decreased by-63.49%
Maintainers
5
Weekly downloads
 
Created
Source

can-define-backup

Build Status

can-define.Map.backup is a plugin that provides a dirty bit for properties on an DefineMap, and lets you restore the original values of an DefineMap's properties after they are changed.

Overview

Here is an example showing how to use [can-define.Map.backup.prototype.backup backup] to save values, [can-define.Map.backup.prototype.restore restore] to restore them, and [can-define.Map.backup.prototype.isDirty isDirty]

to check if the Map has changed:

var recipe = new DefineMap({
	title: "Pancake Mix",
	yields: "3 batches",
	ingredients: [{
		ingredient: "flour",
		quantity: "6 cups"
	},{
		ingredient: "baking soda",
		quantity: "1 1/2 teaspoons"
	},{
		ingredient: "baking powder",
		quantity: "3 teaspoons"
	},{
		ingredient: "salt",
		quantity: "1 tablespoon"
	},{
		ingredient: "sugar",
		quantity: "2 tablespoons"
	}]
});
defineBackup(recipe);
recipe.backup();

recipe.title = "Flapjack Mix";
recipe.title;     // "Flapjack Mix"
recipe.isDirty(); // true

recipe.restore();
recipe.title;     // "Pancake Mix"

Usage

ES6 use

With StealJS, you can import this module directly in a template that is autorendered:

import defineBackup from "can-define-backup";

CommonJS use

Use require to load can-define-backup and everything else needed to create a template that uses can-define-backup:

var defineBackup = require("can-define-backup");

AMD use

Configure the can and jquery paths and the can-define-backup package:

<script src="require.js"></script>
<script>
	require.config({
	    paths: {
	        "jquery": "node_modules/jquery/dist/jquery",
	        "can": "node_modules/canjs/dist/amd/can"
	    },
	    packages: [{
			name: "can-define-backup",
			location: "node_modules/can-define-backup/dist/amd",
			main: "lib/can-define-backup"
	    }]
	});
	require(["main-amd"], function(){});
</script>

Standalone use

Load the global version of the plugin:

<script src="./node_modules/can-define-backup/dist/global/can-define-backup.js"></script>

Contributing

Making a Build

To make a build of the distributables into dist/ in the cloned repository run

npm install
node build

Running the tests

Tests can run in the browser by opening a webserver and visiting the test.html page. Automated tests that run the tests from the command line in Firefox can be run with

npm test

Keywords

FAQs

Package last updated on 20 Mar 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc