| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- "use strict";
- var FieldRef = module.exports = function FieldRef (){
- this._array = [];
- this._path = '';
- }, klass = FieldRef, base = Object, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
- proto.parse = function parse( str ) {
- this._array = str.split('.');
- this._path = this._array.join('.');
- };
- proto.setPart = function setPart( i, part ) {
- this._array[i] = part;
- this._path = this._array.join('.');
- };
- proto.getPart = function getPArt( i ) {
- return this._array[i];
- };
- proto.isPrefixOf = function isPrefixOf( other ) {
- return ( other._path.indexOf(this.path) === 0 );
- };
- proto.commonPrefixSize = function commonPrefixSize ( other ) {
- var i = 0;
- while(other._array[i] == this._array[i]) { i++; }
- return i;
- };
- proto.dottedField = function dottedField( ) {
- var offset = 0;
- if(arguments.length == 1){
- offset = arguments[0];
- }
- return this._array.slice( offset ).join('.');
- };
- proto.equalsDottedField = function equalsDottedField ( other ) {
- return this._path == other._path;
- };
- proto.compare = function compare( other ) {
- return (this._path < other._path ? -1 : this._path > other._path ? 1 : 0);
- };
- proto.clear = function clear() {
- this._path = '';
- this._array = [];
- };
- proto.numParts = function numParts() {
- return this._array.length;
- };
- proto.numReplaced = function numReplaced() {
- throw new Error('Why?');
- };
|