# funcsync

> JavaScript's function client-server synchronization helper library.

Latest version **1.2.1** (published 2014-04-18) · 0 weekly downloads

## Install

```sh
npm install funcsync
pnpm add funcsync
yarn add funcsync
bun add funcsync
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2014-04-18 |
| First published | 2013-06-05 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Imre Fazekas |
| Maintainers | imre.fazekas |
| Keywords | util, function, server, client, synchronization |

## Links

- npm: https://www.npmjs.com/package/funcsync
- Repository: https://github.com/imrefazekas/funcsync
- Issues: http://github.com/imrefazekas/funcsync/issues
- npm.io page: https://npm.io/package/funcsync

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 1.2.1 (latest) — 2014-04-18
- 1.2.0 — 2014-04-18
- 1.1.4 — 2014-02-15
- 1.1.3 — 2014-02-14
- 1.1.2 — 2014-01-02
- 1.1.1 — 2013-09-25
- 1.1.0 — 2013-09-19
- 1.0.9 — 2013-08-20
- 1.0.8 — 2013-08-20
- 1.0.7 — 2013-07-15
- 1.0.6 — 2013-07-15
- 1.0.5 — 2013-07-05
- 1.0.4 — 2013-07-04
- 1.0.3 — 2013-06-30
- 1.0.2 — 2013-06-28
- … 2 more at https://npm.io/package/funcsync/versions

## README

funcsync
========

[Funcsync](https://github.com/imrefazekas/funcsync) is a dependency-free extremely small library helping to exchange/synchronize functions between server and client side. 

Prepares an object - might containing business logic as function - for sending in a text format (JSON for example) and vice versa.

Usage:

- [Server-side](#server-side)
- [Client-side](#client-side)


## Server-side

Command line:

	npm install funcsync

In [node.js](www.nodejs.org) code:

	var f = require('funcsync');
	...
	var obj = {
		"tab1":[
			function test1(){ console.log("My "); },
			function test2(){ console.log("dear "); }
		],
		"tab2":{ "test3": function(){ console.log("user:" + self.name); } }
	};
	...
	f.stringify( obj ) // prepare the given object for sending
	...
	var fs = f.functify( obj, {nane:'Bob'} ); // retrieve functions from the obj received
	fs.tab2.test3();

#### Bind context

The function _functify_ has an optional second parameter: _context_. 
All function will access this context, through the variable name _self_ while being executed. 

This way you can __bind__ a [knockout.js](http://knockoutjs.com) viewmodel or anything you want and can access it via the name _'self'_.

## Client-side

In _head_

	<script src='funcsync.min.js'></script>

In any _script_ tag

	funcsync.stringify( obj );


For a more complex scenario please find a complex project boilerplate: [Division.js](https://github.com/imrefazekas/division.js), where one business model is defined and maintained allowing you to use the same objects - including model and validation and computed values and associated functions - on both client side, server side and DB interaction!

---
_Source: https://npm.io/package/funcsync · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
