Skip to content

Commit d0991d5

Browse files
committed
Merge branch 'improve-docs'
2 parents 7c43a97 + d6a0310 commit d0991d5

File tree

12 files changed

+61
-13
lines changed

12 files changed

+61
-13
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,19 @@ See files under `examples/` on how to use.
8282

8383
This runs the test suite against a fresh download of Neo4j.
8484
Or `npm test` if you already have a running version of a compatible Neo4j server.
85+
86+
## A note on numbers and the Integer type
87+
For this driver to fully map to the Neo4j type system handling of 64-bits Integers is needed.
88+
Javascript can saftely represent numbers between `-(2`<sup>`53`</sup>` - 1)` and `(2`<sup>`53`</sup>` - 1)`.
89+
Therefore, an Integer type is introduced.
90+
91+
### Write integers
92+
Number written directly e.g. `session.run("CREATE (n:Node {age: {age}})", {age: 22})` will be of type `Float` in Neo4j.
93+
To write the `age` as an integer the `neo4j.int` method should be used.
94+
E.g. `session.run("CREATE (n:Node {age: {age}})", {age: neo4j.int(22)})`.
95+
96+
### Read integers
97+
To get the value of a from Neo4j received integer, the safeast way would be to use the `.toString()` method on
98+
an Integer object.
99+
E.g. `console.log(result.age.toString())`.
100+
To check if a variable is of the Integer type, the method `neo4j.isInt(variable)` can be used.

lib/graph-types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class Relationship {
9090

9191
/**
9292
* Class for UnboundRelationship Type.
93+
* @access private
9394
*/
9495
class UnboundRelationship {
9596
/**

lib/internal/integer.js renamed to lib/integer.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
/**
2525
* Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers.
2626
* See the from* functions below for more convenient ways of constructing Integers.
27+
* @access public
2728
* @exports Integer
2829
* @class A Integer class for representing a 64 bit two's-complement integer value.
2930
* @param {number} low The low (signed) 32 bits of the long
@@ -585,6 +586,7 @@ Object.defineProperty(Integer.prototype, "__isInteger__", {
585586

586587
/**
587588
* Tests if the specified object is a Integer.
589+
* @access private
588590
* @param {*} obj Object
589591
* @returns {boolean}
590592
* @expose
@@ -605,6 +607,7 @@ var INT_CACHE = {};
605607

606608
/**
607609
* Returns a Integer representing the given 32 bit integer value.
610+
* @access private
608611
* @param {number} value The 32 bit integer in question
609612
* @returns {!Integer} The corresponding Integer value
610613
* @expose
@@ -625,6 +628,7 @@ Integer.fromInt = function(value) {
625628

626629
/**
627630
* Returns a Integer representing the given value, provided that it is a finite number. Otherwise, zero is returned.
631+
* @access private
628632
* @param {number} value The number in question
629633
* @returns {!Integer} The corresponding Integer value
630634
* @expose
@@ -644,6 +648,7 @@ Integer.fromNumber = function(value) {
644648
/**
645649
* Returns a Integer representing the 64 bit integer that comes by concatenating the given low and high bits. Each is
646650
* assumed to use 32 bits.
651+
* @access private
647652
* @param {number} lowBits The low 32 bits
648653
* @param {number} highBits The high 32 bits
649654
* @returns {!Integer} The corresponding Integer value
@@ -655,6 +660,7 @@ Integer.fromBits = function(lowBits, highBits) {
655660

656661
/**
657662
* Returns a Integer representation of the given string, written using the specified radix.
663+
* @access private
658664
* @param {string} str The textual representation of the Integer
659665
* @param {number=} radix The radix in which the text is written (2-36), defaults to 10
660666
* @returns {!Integer} The corresponding Integer value
@@ -696,6 +702,7 @@ Integer.fromString = function(str, radix) {
696702

697703
/**
698704
* Converts the specified value to a Integer.
705+
* @access private
699706
* @param {!Integer|number|string|!{low: number, high: number}} val Value
700707
* @returns {!Integer}
701708
* @expose
@@ -794,10 +801,24 @@ Integer.MAX_VALUE = Integer.fromBits(0xFFFFFFFF|0, 0x7FFFFFFF|0, false);
794801
*/
795802
Integer.MIN_VALUE = Integer.fromBits(0, 0x80000000|0, false);
796803

797-
804+
/**
805+
* Cast value to Integer type.
806+
* @access public
807+
* @param {Mixed} value - The value to use.
808+
* @return {Integer} - An object of type Integer.
809+
*/
798810
let int = Integer.fromValue;
799811

812+
/**
813+
* Check if a variable is of Integer type.
814+
* @access public
815+
* @param {Mixed} value - The varaible to check.
816+
* @return {Boolean} - Is it of the Integer type?
817+
*/
818+
let isInt = Integer.isInteger;
819+
800820
export default {
801821
Integer,
802-
int
822+
int,
823+
isInt
803824
}

lib/internal/buf.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ let _node = require("buffer");
3030
* stateful read/write methods.
3131
* readXXX and writeXXX-methods move the inner position of the buffer.
3232
* putXXX and getXXX-methods do not.
33-
* @access public
33+
* @access private
3434
*/
3535
class BaseBuffer
3636
{
@@ -355,6 +355,7 @@ class BaseBuffer
355355

356356
/**
357357
* Basic buffer implementation that should work in most any modern JS env.
358+
* @access private
358359
*/
359360
class HeapBuffer extends BaseBuffer {
360361
constructor (arg) {
@@ -403,6 +404,7 @@ class HeapBuffer extends BaseBuffer {
403404

404405
/**
405406
* Represents a view of slice of another buffer.
407+
* @access private
406408
*/
407409
class SliceBuffer extends BaseBuffer {
408410
constructor( start, length, inner ) {
@@ -438,6 +440,7 @@ class SliceBuffer extends BaseBuffer {
438440

439441
/**
440442
* Buffer that combines multiple buffers, exposing them as one single buffer.
443+
* @access private
441444
*/
442445
class CombinedBuffer extends BaseBuffer {
443446
constructor (buffers) {
@@ -478,6 +481,7 @@ class CombinedBuffer extends BaseBuffer {
478481

479482
/**
480483
* Buffer used in a Node.js environment
484+
* @access private
481485
*/
482486
class NodeBuffer extends BaseBuffer {
483487
constructor(arg) {
@@ -540,6 +544,7 @@ try {
540544
/**
541545
* Allocate a new buffer using whatever mechanism is most sensible for the
542546
* current platform
547+
* @access private
543548
* @param {Integer} size
544549
* @return new buffer
545550
*/

lib/internal/ch-node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ let _CONNECTION_IDGEN = 0;
2525
/**
2626
* In a Node.js environment the 'net' module is used
2727
* as transport.
28-
* @access public
28+
* @access private
2929
*/
3030

3131
class NodeChannel {

lib/internal/ch-websocket.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {HeapBuffer} from "./buf";
2222

2323
/**
2424
* Create a new WebSocketChannel to be used in web browsers.
25-
* @access public
25+
* @access private
2626
*/
2727
class WebSocketChannel {
2828

lib/internal/chunking.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ let
2626

2727
/**
2828
* Looks like a writable buffer, chunks output transparently into a channel below.
29+
* @access private
2930
*/
3031
class Chunker extends buf.BaseBuffer {
3132
constructor( channel, bufferSize ) {
@@ -129,6 +130,7 @@ class Chunker extends buf.BaseBuffer {
129130
/**
130131
* Combines chunks until a complete message is gathered up, and then forwards that
131132
* message to an 'onmessage' listener.
133+
* @access private
132134
*/
133135
class Dechunker {
134136
constructor() {

lib/internal/connector.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ let _mappers = {
146146
* to call 'sync' when messages need to be sent, and it routes response
147147
* messages back to the originators of the requests that created those
148148
* response messages.
149-
* @access public
149+
* @access private
150150
*/
151151
class Connection {
152152
/**
@@ -312,6 +312,7 @@ class Connection {
312312

313313
/**
314314
* Crete new connection to the provided url.
315+
* @access private
315316
* @param {string} url - 'neo4j'-prefixed URL to Neo4j Bolt endpoint
316317
* @return {Connection} - New connection
317318
*/

lib/internal/packstream.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import {debug} from "./log";
2121
import {alloc} from "./buf";
2222
import utf8 from "./utf8";
23-
import {Integer, int} from "./integer";
23+
import {Integer, int} from "../integer";
2424

2525
let MAX_CHUNK_SIZE = 16383,
2626
TINY_TEXT = 0x80,
@@ -49,7 +49,7 @@ STRUCT_16 = 0xDD;
4949

5050
/**
5151
* A Structure have a signature and fields.
52-
* @access public
52+
* @access private
5353
*/
5454
class Structure {
5555
/**
@@ -76,7 +76,7 @@ class Structure {
7676

7777
/**
7878
* Class to pack
79-
* @access public
79+
* @access private
8080
*/
8181
class Packer {
8282
constructor (channel) {
@@ -241,7 +241,7 @@ class Packer {
241241

242242
/**
243243
* Class to unpack
244-
* @access public
244+
* @access private
245245
*/
246246
class Unpacker {
247247
constructor () {

lib/stream-observer.js renamed to lib/internal/stream-observer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* for the incoming stream is registered. Thus, we keep fields around
2626
* for tracking head/records/tail. These are only used if there is no
2727
* observer registered.
28+
* @access private
2829
*/
2930
class StreamObserver {
3031
/**

0 commit comments

Comments
 (0)