Converts DynamoDb "S", "B", "BS", "BOOL" to values.

@param item
@returns {*}
969758
function unmarshalPassThrough(item) {
  var key = _.find(function(type) {
    return _.has(type, item);
  }, ['S', 'B', 'BS', 'BOOL']);

  return !key ? void 0 : item[key];
}
514179
function(val, item) {
    if (_.isString(val)) return val.indexOf(item) !== -1;
    if (_.isArray(val))  return _.indexOf(val, item) !== -1;
    if (_.isObject(val)) return _.has(val, item);
    return false;
  }
943456
def is_dynamo_value(value):
    
    if not isinstance(value, dict) or len(value) != 1:
        return False
    subkey = six.next(six.iterkeys(value))
    return subkey in TYPES_REV
1081344
function transformItem(stream, item) {
    var ret;
    if (isArray(item)) {
        if (isHashArray(item)) {
            ret = transformHashArrayData(stream, item);
        } else {
            ret = transformArrayData(stream, item);
        }
    } else {
        ret = transformHashData(stream, item);
    }
    return ret;
}
522388
public int findItemOnlyIdx(JQMListItem item) {
        if (item == null) return -1;
        List<JQMListItem> items = getItems();
        if (items == null) return -1;
        int i = items.indexOf(item);
        if (i == -1) return -1;
        int j = 0;
        for (JQMListItem k : items) {
            if (k == null) continue;
            if (k == item) return j;
            j++;
        }
        return -1;
    }
542964
function (type, item) {
        switch(type) {
            case simpleTypes.undefined:
            case simpleTypes.null:
                return true;
            case simpleTypes.string:
                if (item.trim().length === 0) {
                    return true;
                }
                return false;
            case simpleTypes.object:
                return (Object.keys(item).length === 0);
            case simpleTypes.array:
                return (item.length === 0);
            default:
                return false;
        };
    }
1158927
function (item){
            for(var i= 0, _len = this.length; i < _len; i++){
                if (this[i] === item){
                    return i;
                }
            }

            return -1;
        }
1096124
def _convert_item(self, item):
        
        item = self.parse_item(item)

        # name is required
        if not item['name']:
            raise Exception('Expected property %s not found in item %s.' % (self.keys['name'], item))
        elif len(item['name']) > 75:
            item['name'] = item['name'][:75]

        if not item['status']:
            item['status'] = self.default_status

        # get status or get default status or None
        try:
            item['status'] = Status.objects.get(slug__iexact=item['status'])
        except Status.DoesNotExist:
            try:
                item['status'] = Status.objects.create(name=item['status'],
                                                       slug=slugify(item['status']),
                                                       description=item['status'],
                                                       is_default=False)
            except Exception as e:
                logger.exception(e)
                item['status'] = None

        # slugify slug
        item['slug'] = slugify(item['name'])

        if not item['address']:
            item['address'] = ''

        if not item['is_published']:
            item['is_published'] = ''

        User = get_user_model()
        # get user or None
        try:
            item['user'] = User.objects.get(username=item['user'])
        except User.DoesNotExist:
            item['user'] = None

        if not item['elev']:
            item['elev'] = None

        if not item['description']:
            item['description'] = ''

        if not item['notes']:
            item['notes'] = ''

        if item['added']:
            # convert dates to python datetime
            try:
                item['added'] = parser.parse(item['added'])
            except Exception as e:
                print "Exception while parsing 'added' date: %s" % e
        if item['updated']:
            try:
                item['updated'] = parser.parse(item['updated'])
            except Exception as e:
                print "Exception while parsing 'updated' date: %s" % e

        result = {
            "name": item['name'],
            "slug": item['slug'],
            "status": item['status'],
            "address": item['address'],
            "is_published": item['is_published'],
            "user": item['user'],
            "geometry": item['geometry'],
            "elev": item['elev'],
            "description": item['description'],
            "notes": item['notes'],
            "added": item['added'],
            "updated": item['updated'],
            "data": {}
        }

        # ensure all additional data items are strings
        for key, value in item['data'].items():
            result["data"][key] = value

        return result
1048459
function toCursor(item, index) {
  const id = item.id;
  return base64(cursorPrefix + id + cursorSeparator + index);
}
651153
def convert_items(self, items):
        """"""
        return ((key, self.convert(value, self)) for key, value in items)
640554
public static boolean toBoolean(Object obj, boolean defaultValue) {

        if (obj == null) {
            return defaultValue;
        }

        if (obj instanceof Boolean) {
            return ((Boolean) obj).booleanValue();
        } else if (obj instanceof Number || obj.getClass().isPrimitive()) {
            int value = toInt(obj);
            return value != 0 ? true : false;
        } else if (obj instanceof Value) {
            return ((Value) obj).booleanValue();
        } else if (obj instanceof String || obj instanceof CharSequence) {
            String str = Conversions.toString(obj);
            if (str.length() == 0) {
                return false;
            }
            if (str.equals("false")) {
                return false;
            } else {
                return true;
            }
        } else if (isArray(obj)) {
            return len(obj) > 0;
        } else if (obj instanceof Collection) {

            if (len(obj) > 0) {
                List list = Lists.list((Collection) obj);
                while (list.remove(null)) {

                }
                return Lists.len(list) > 0;
            } else {
                return false;
            }
        } else {
            return toBoolean(Conversions.toString(obj));
        }
    }
495241
def dynamize_value(self, val):
        
        def _str(val):
            """
            DynamoDB stores booleans as numbers. True is 1, False is 0.
            This function converts Python booleans into DynamoDB friendly
            representation.
            """
            if isinstance(val, bool):
                return str(int(val))
            return str(val)

        dynamodb_type = self.get_dynamodb_type(val)
        if dynamodb_type == 'N':
            val = {dynamodb_type : _str(val)}
        elif dynamodb_type == 'S':
            val = {dynamodb_type : val}
        elif dynamodb_type == 'NS':
            val = {dynamodb_type : [ str(n) for n in val]}
        elif dynamodb_type == 'SS':
            val = {dynamodb_type : [ n for n in val]}
        return val
184853
function(item) {
        if (item && Selectivity.isValidId(item.id) && isString(item.text)) {
            return item;
        } else {
            throw new Error('Item should have id (number or string) and text (string) properties');
        }
    }
137939
def decode(self, dynamo_value):
        
        type, value = next(six.iteritems(dynamo_value))
        if type == STRING:
            return value
        elif type == BINARY:
            return Binary(value)
        elif type == NUMBER:
            return Decimal(value)
        elif type == STRING_SET:
            return set(value)
        elif type == BINARY_SET:
            return set((Binary(v) for v in value))
        elif type == NUMBER_SET:
            return set((Decimal(v) for v in value))
        elif type == BOOL:
            return value
        elif type == LIST:
            return [self.decode(v) for v in value]
        elif type == MAP:
            decoded_dict = {}
            for k, v in six.iteritems(value):
                decoded_dict[k] = self.decode(v)
            return decoded_dict
        elif type == NULL:
            return None
        else:
            raise TypeError("Received unrecognized type %r from dynamo", type)
678060
protected function normalizeValue($item, $fromDb = false)
    {
        $entityClass = $this->entityClass;
        $itemEntity = null;

        // $item can be an array of data or AbstractEntity
        if ($this->isInstanceOf($item, $entityClass)) {
            return $item;
        }

        if ($this->isArray($item) || $this->isArrayObject($item)) {
            if (isset($item['id'])) {
                // Try getting the instance from cache
                $itemEntity = Entity::getInstance()->get($entityClass, $item['id']);
                if ($itemEntity) {
                    return $itemEntity;
                }

                // If not found in cache, load from database
                $itemEntity = $entityClass::findById($item['id']);
            }
        }

        // If instance was not found, create a new entity instance
        if (!$itemEntity) {
            $itemEntity = new $entityClass;
        }

        // If $item is an array - use it to populate the entity instance
        if ($this->isArray($item) || $this->isArrayObject($item)) {
            if ($fromDb) {
                $item['__webiny_db__'] = true;
            }

            $itemEntity->populate($item);
        }

        return $itemEntity;
    }
218197
function toKeyValueStrings(dynamoDBMap) {
  return dynamoDBMap && typeof dynamoDBMap === 'object' ?
    Object.getOwnPropertyNames(dynamoDBMap).map(key => `${key}:${stringify(toValueFromAttributeValue(dynamoDBMap[key]))}`) : [];
}
154975
def _convert_value(self, item):
        
        # Types:
        # 0 = empty u''
        # 1 = unicode text
        # 2 = float (convert to int if possible, then convert to string)
        # 3 = date (convert to unambiguous date/time string)
        # 4 = boolean (convert to string "0" or "1")
        # 5 = error (convert from code to error text)
        # 6 = blank u''

        # Thx to Augusto C Men to point fast solution for XLS/XLSX dates
        if item.ctype == 3:  # XL_CELL_DATE:
            try:
                return datetime.datetime(*xlrd.xldate_as_tuple(item.value, self._book.datemode))
            except ValueError:
                # TODO: make toggable
                # Invalid date
                return item.value

        if item.ctype == 2:  # XL_CELL_NUMBER:
            if item.value % 1 == 0:  # integers
                return int(item.value)
            else:
                return item.value

        return item.value