Provides binary operations, arithmetic operations, iterators, and allows for custom operations.
Classes
Methods
(inner) add(value) → {this}
Perform addition operation to an IP instance
Parameters:
Name | Type | Description |
---|---|---|
value | IPv4 | | The mask value |
Returns:
A pointer to itself
- Type:
- this
(inner) and(mask) → {this}
Perform an AND operation to an IP instance
Parameters:
Name | Type | Description |
---|---|---|
mask | IPv4 | | The mask value |
Returns:
A pointer to itself
- Type:
- this
(inner) ceil() → {this}
Every byte which is not 0, is set to 255
Returns:
A pointer to itself
- Type:
- this
(inner) floor() → {this}
Every byte which is not 255, is set to 0
Returns:
A pointer to itself
- Type:
- this
(inner) it(operation) → {this}
Iterate through an IPv4 instance's bytes
Parameters:
Name | Type | Description |
---|---|---|
operation | function | An operation to run, takes 2 arguments, the byte data (0 to 255) and the byte index |
Returns:
A pointer to itself
- Type:
- this
Example
ip.copy()
.it((byte, byte_index) => {
return (byte & mask.u8(byte_index))
})
.log();
(inner) or(mask) → {this}
Perform an OR operation to an IP instance
Parameters:
Name | Type | Description |
---|---|---|
mask | IPv4 | | The mask value |
Returns:
A pointer to itself
- Type:
- this
(inner) shift_left(bits) → {this}
Shift the IPv4 bits left
Parameters:
Name | Type | Description |
---|---|---|
bits | Number | The number of bits to shift the IPv4 instance |
Returns:
A pointer to itself
- Type:
- this
(inner) shift_right(bits) → {this}
Shift the IPv4 bits right
Parameters:
Name | Type | Description |
---|---|---|
bits | Number | The number of bits to shift the IPv4 instance |
Returns:
A pointer to itself
- Type:
- this
(inner) xor(mask) → {this}
Perform an XOR operation to an IP instance
Parameters:
Name | Type | Description |
---|---|---|
mask | IPv4 | | The mask value |
Returns:
A pointer to itself
- Type:
- this