Skip to content

Releases: YahooArchive/express-state

Upgrade serialize-javascript to 3.x

29 Apr 03:34
Compare
Choose a tag to compare
  • Upgrade serialize-javascript to version 3.0.0 (#41).

Added isJSON Option for Faster Serialization

31 May 22:11
Compare
Choose a tag to compare

This adds support for the isJSON option to help speed up serialization for pure JSON data.

res.expose({foo: 'bar'}, 'foo', {isJSON: true});

See: yahoo/serialize-javascript#17

Express State v1.3.0 — Externalized serialize-javascript Package

26 Aug 20:46
Compare
Choose a tag to compare

This minor release is for the externalization of the serialize-javascript package which Express State now depends on.


View 1.3.0 Changelog

Express State v1.2.0 — Express v4.x

29 Apr 00:24
Compare
Choose a tag to compare

This minor release adds support for Express v4.x by simply updating this package's peer dependency to >=3.x. All unit tests pass when tested against Express v4.x. Thanks to @NoumanSaleem for testing and getting these changes in place for this release!


View 1.2.0 Changelog

Express State v1.1.4 — Value Bug Fix

03 Apr 23:05
Compare
Choose a tag to compare

This patch release fixes an issue where pre-serialized values from a parent Exposed object were being used instead of an Exposed object's own values. The process of getting a serialized value for a given namespace has been improved to properly follow the semantics of Exposed object hierarchy. (#25)

app.expose(1, 'foo', {cache: true});
res.expose(2, 'foo');

The above now results in the following, as expected:

console.log(window.foo); // => 2

View 1.1.4 Changelog

Express State v1.1.3 — Output Bug Fix

06 Mar 23:39
Compare
Choose a tag to compare

This patch release fixes an issue where an error would be thrown when evaluating the JavaScript output of exposed data with deep namespaces (#23).

The following will no longer throw an error when its output is evaluated in the browser:

app.expose({}, 'foo');
app.expose('baz', 'foo.bar.baz');

Previously, this would output the following and throw because root.foo.bar was undefined:

root.foo || (root.foo = {});
root.foo.bar || (root.foo.bar = {});

root.foo = {};
root.foo.bar.baz = "baz";

Now, the namespaces are initialized next to where data will be assigned to them and now outputs the following:

root.foo = {};
root.foo || (root.foo = {});
root.foo.bar || (root.foo.bar = {});
root.foo.bar.baz = "baz";

Thanks to @jeremyruppel for finding the bug and contributing the fix!


View 1.1.3 Changelog

Express State v1.1.2 — Line Terminators

21 Feb 05:39
Compare
Choose a tag to compare

This patch release fixes an issues with line terminator characters (U+2028 and U+2029) being handled differently in JavaScript vs. JSON by escaping them (#21, #22).

Thanks to @norwood and @mathiasbynens for helping with this!


View 1.1.2 Changelog

Express State v1.1.1

25 Jan 20:54
Compare
Choose a tag to compare

This is a minor patch release that makes request-scope exposed data always inherit the app-scope exposed data. Now if a request comes in before data is exposed at the app-scope, the app.locals.state object will be created first. This ensures the semantics of the relationship between app- and request-scoped exposed data.


View 1.1.1 Changelog

Express State v1.1.0 — Performance

23 Jan 03:55
Compare
Choose a tag to compare

Certain apps pump a lot of data from the server to the client via Express State. This release greatly improves performance of serializing unchanging data with the new {cache: true} option for the app.expose() and res.expose() methods.

Increasing Performance

Lazy serialization of exposed data is a primary feature of Express State. Exposed data objects are stored by reference, making them "live" and allowing their values to be updated even after the object has been passed to the expose() method. And this is great for data which is dynamic per-request. But when data is unchanging/static, this means Express State runs through its serialization process for every request yielding the same result.

To avoid having Express State perform its serialization process for the same, static, data object, the new {cache: true} option can be used:

var CONFIG = {
    hostname : 'example.com',
    someOther: 'constant value'
};

app.expose(CONFIG, 'MY_APP.config', {cache: true});

Setting this option allows Express State to optimize the serialization process
by keeping the serialized value around and re-using it every time the
toString() method is invoked (which happens for every request.)

Benchmark Results

As part of the development of the new {cache: true} option, benchmark tests have been added Express State; these include real-world fixture data from Photos Near Me and Yahoo Tech.

Serializing a simple object:

simple.toString() x 220,056 ops/sec ±3.56% (84 runs sampled)
simpleCached.toString() x 1,972,394 ops/sec ±4.58% (85 runs sampled)

Photos Near Me's static app-scoped data:

pnmApp.toString() x 15,840 ops/sec ±5.44% (84 runs sampled)
pnmAppCached.toString() x 241,270 ops/sec ±4.92% (83 runs sampled)

Yahoo Tech's static app-scoped data:

ytApp.toString() x 9,509 ops/sec ±6.08% (85 runs sampled)
ytAppCached.toString() x 339,479 ops/sec ±5.94% (71 runs sampled)

When data can be eagerly serialized by Express State, like static app-level configuration, the result of using the {cache: true} option can improve repeated, per-request serialization by: 8x – 36x!

With these kinds of performance gains and when a large amount of data needs to be exposed to the client-side, it is recommended to come up with a strategy where all data which is common to most/every request be exposed at the app-scope with the {cache: true} option set.

Deprecations

In order to support the new cache option, the expose( obj, namespace, local ) API signature has been deprecated. The third argument is now options, use: expose( obj, namespace, {local: local}). The deprecated signature will be removed in a future release, and logs a warning when it is used.


View 1.1.0 Changelog

Express State v1.0.3

04 Dec 17:27
Compare
Choose a tag to compare

This is a minor patch release, but if you're using Express State v1.0.0 you should upgrade to get the XSS protection added in v1.0.1.

This releases fixed an issue with npm test so that it now runs on Windows. A .npmignore file has also been added to only bundle the essential files when creating the npm package.


View 1.0.3 Changelog